简体   繁体   中英

Asset path notation in Ruby on Rails

How do I include several Javascript and CSS files in my Ruby on Rails project?

Instead of having the files in assets/javascript and assets/stylesheets , the files are in directories of /css and /js . There is also a large number of subfolders within those directories.

I tried updating the manifest.js file and also tried including several of stylesheet links in the application.html.erb , but I the files are not being included in my project.

I would much rather point the manifest file at the folders I need so if I have files in all folders under assets/css/subfolder/subfolder/subfolder , how would I do this?

I have the same question for Javascript files.

Use require_tree to include your parent /js and /css directories.

You could then do something like this

# application.js    
//= require_tree ./js

# application.css
*= require_tree ./css

Check out this comparable StackOverflow post

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