In Rails 3.1…
This is my application.css: /*
*= require_self
*= require_tree .
*/
This is my application.js:
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require_tree .
What does the “require_tree .” do?
In Rails 3.1…
This is my application.css: /*
*= require_self
*= require_tree .
*/
This is my application.js:
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require_tree .
What does the “require_tree .” do?
The first three requires bring in the files in vendor/assets/javascripts
, while the lastrequire_tree .
tells sprockets to require everything in the same directory. The require order is alphabetical, so you may have to move things around or be more specific to correctly get your dependencies in order.
It’s slightly smarter than alphabetical. You can use #require_tree to pull in the entire tree and then within individual sub files use #require to force the ordering of specific files
Thanks. This site - http://ryanbigg.com/guides/asset_pipeline.html - explained it pretty well…