What does "require tree" do in Rails 3.1?

266 views
Skip to first unread message

David Zhang

unread,
Jul 19, 2011, 5:07:59 AM7/19/11
to rubyonra...@googlegroups.com
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?

rajeevsharma86

unread,
Jul 19, 2011, 5:17:40 AM7/19/11
to rubyonra...@googlegroups.com
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.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/VYCzvxOHRwMJ.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.



--
Rajeev Kannav Sharma

Brad Phelan

unread,
Jul 19, 2011, 12:16:23 PM7/19/11
to rubyonra...@googlegroups.com
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

David Zhang

unread,
Jul 21, 2011, 3:57:45 PM7/21/11
to rubyonra...@googlegroups.com
Thanks. This site - http://ryanbigg.com/guides/asset_pipeline.html - explained it pretty well...
Reply all
Reply to author
Forward
0 new messages