Reputation: 11
I'm attempting to port from Rails 2.3.8 to Rails 3.2.6. My app currently uses 3rd party css/js/images which are placed in public/<3rdparty>/<subdir>/../..
In layout/application.html.erb
, I used absolute path to retrieve them; eg <%= stylesheet_link_tag "/dojoroot/dojo/resources/dojo.css" %>
and <%= javascript_include_tag "/dojoroot/dojo/dojo.js" %>
For Rails 3.2.6, the assets are expected to be in app/assets
or lib/assets
. However, moving the 3rd party from public to app/assets doesn't work because the tag are looking for the assets under their respective type. For example, <%= stylesheet_link_tag "dojoroot/dojo/resources/dojo.css" %>
will look at app/assets/stylesheet/dojoroot/dojo/resources/dojo.csc
and likewise the javascripts will look under apps/assets/javascripts/dojoroot/dojo/dojo.js
. Breaking the 3rd party into 3 subdirs of stylesheets/javascripts/images seem rather wasteful and timeconsuming.
If I pass the absolute path to the tag; eg <%= javascript_include_tag "/dojoroot/dojo/dojo.js" %>
Rails won't find it in app/assets/dojoroot.
Is there a configuration where I can have Rails look for the assets without injecting "stylesheets", "javascripts" into the path?
Upvotes: 1
Views: 440
Reputation: 14943
Just name the file, no path
<%= stylesheet_link_tag "dojo" %>
If you want to reference more than one, you can do
<%= stylesheet_link_tag "dojo", "custom" %>
Also, make sure in app/assets/javascript/application.js that you have
//= require jquery
//= require jquery_ujs
//= require_tree .
And <%= javascript_include_tag(:application) %>
in your application.html.erb
read '2.1.2 Using index files' in http://edgeguides.rubyonrails.org/asset_pipeline.html
Upvotes: 1