Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3.1 and Coffeescript: Require entire directory

There is a require for individual files like so:

//= require controllers/documents

Is there an equivalent for requiring a directory?

like image 656
miketucker Avatar asked Nov 29 '22 04:11

miketucker


1 Answers

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.

like image 171
Trevor Burnham Avatar answered Dec 07 '22 00:12

Trevor Burnham