简体   繁体   English

Ruby on Rails中的资产路径表示法

[英]Asset path notation in Ruby on Rails

How do I include several Javascript and CSS files in my Ruby on Rails project? 如何在Ruby on Rails项目中包含几个Javascript和CSS文件?

Instead of having the files in assets/javascript and assets/stylesheets , the files are in directories of /css and /js . 这些文件位于/css/js目录中,而不是在assets/javascriptassets/stylesheets中包含文件。 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. 我尝试更新manifest.js文件,还尝试在application.html.erb包含多个样式表链接,但我的文件未包含在我的项目中。

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? 我宁愿将清单文件指向所需的文件夹,因此,如果在assets/css/subfolder/subfolder/subfolder下的所有文件夹中都有文件,我该怎么做?

I have the same question for Javascript files. 我对Javascript文件有相同的问题。

Use require_tree to include your parent /js and /css directories. 使用require_tree包含您的父目录/js/css

You could then do something like this 然后你可以做这样的事情

# application.js    
//= require_tree ./js

# application.css
*= require_tree ./css

Check out this comparable StackOverflow post 看看这篇类似的StackOverflow 帖子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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