我刚开始使用我的第一个ruby应用程序。
我将我的应用程序所需的css和js文件复制到assets文件夹,当我运行应用程序时,所有css和js都加载到页面,我不想要那个
我的观点很简单
hello
我的application.css只是评论
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
为什么要加载所有资产? 我可以“禁用”这个吗?
我想要的只是定义具有特定顺序的视图文件中所需的文件(css,js)和仅为特定页面所需的加载js
答案 0 :(得分:3)
答案 1 :(得分:0)
如果你写* =需要树,这意味着将添加javascript文件夹中的所有j,并且对于css也是如此。所以删除那些行。同时,您可以使用资产管理器到您的应用程序来管理您的资产(使其特定于页面)以进行资产管理,我建议您检查http://railscasts.com/episodes/279-understanding-the-asset-pipeline?view=asciicast和https://rails-assets.org/