Question

There is a require for individual files like so:

//= require controllers/documents

Is there an equivalent for requiring a directory?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top