[英]ruby on rails and assets
我刚刚启动了我的第一个ruby应用程序。
我将应用程序所需的css和js文件复制到资产文件夹,当我运行该应用程序时,所有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。
如果您编写* = require树,这意味着将添加javascript文件夹上的所有js,并且对css也是如此。 因此删除这些行。 同时,您可以对应用程序使用资产管理器来管理您的资产(使其在特定页面上显示)以进行标准资产管理。我建议您检查http://railscasts.com/episodes/279-understanding-the -asset-pipeline?view = asciicast和https://rails-assets.org/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.