There is a require for individual files like so:
//= require controllers/documents
Is there an equivalent for requiring a directory?
Yep:
//= require_tree controllers
By the way, you tagged this as coffeescript
, but your question uses JavaScript comment syntax... so for the record, in CoffeeScript you want to use #=
, not //=
.
Also, this is actually a Sprockets question, not a Rails question. Sprockets is a default in Rails 3.1, but you can use it independently as well. At any rate, the Sprockets page offers documentation aplenty on require
, require_tree
, and many other handy directives.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With