简体   繁体   中英

How do I require subdirectories of /app/assets/javascripts in Rails 3.1

I want to separate out my javascripts into separate subdirectories in my Rails 3.1 app.

For instance I have a /modules directory inside /app/assets/javascripts

A way to either require all the contents of the directory or each file individually would be helpful.

Edit: To clarify, I want to do this from my application.js coffeescript file.

I believe the way to do this in Sprockets is

#= require_tree modules

or

#= require_tree ./modules

if you want to select a subdirectory relative to the CoffeeScript file, rather than relative to app/assets/javascripts (see this issue ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM