Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails RubyonRails和资产_Ruby On Rails_Ruby_Asset Pipeline - Fatal编程技术网

Ruby on rails RubyonRails和资产

Ruby on rails RubyonRails和资产,ruby-on-rails,ruby,asset-pipeline,Ruby On Rails,Ruby,Asset Pipeline,我刚刚启动了我的第一个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. * *

我刚刚启动了我的第一个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文件。Rails的预处理器解释它并插入您的文件

 *= require_self
 *= require_tree .

阅读。2.4清单文件和指令。

如果您编写*=require树,这意味着将添加javascript文件夹中的所有js,css也是如此。所以,去掉那些线。同时,您可以在应用程序中使用资产管理器来管理您的资产,使其页面特定于机架下的资产管理。我建议您检查和

推荐阅读:谢谢,我刚刚开始