[英]Stop rails from looking for controller specific JS and CSS
I'm using Rails 3.2 (old and unsupported, I know). 我正在使用Rails 3.2(我知道它是旧的,不受支持)。 It's a legacy application upgrade, and we didn't have controller specific
js/css
files previously, we have a different structure for them. 这是旧版应用程序升级,并且以前我们没有控制器特定的
js/css
文件,但它们具有不同的结构。
The problem is that the asset pipeline looks for MyController.js
when I load MyController
or worse: when I load a method it looks for a specific JS or CSS for that view. 问题在于,当我加载
MyController
或更糟时,资产管道会寻找MyController.js
:当我加载方法时,它会为该视图寻找特定的JS或CSS。
Since I have this setting in production.rb
: config.assets.compile = false
it won't fall back to the asset pipeline if something isn't compiled. 因为我在
production.rb
有此设置: config.assets.compile = false
所以如果不进行编译,它将不会退回到资产管道。 This causes errors like device/passwords.js isn't precompiled
which is frustrating because I don't want/need a separate js
file for this. 这会导致
device/passwords.js isn't precompiled
类的错误,这令人沮丧,因为我不需要/不需要单独的js
文件。
Rails 3.2 automatically requires these controller specificjs and , nothing in my code that does that that I know of and I've checked for this: <%= javascript_include_tag params[:controller] %>
which also doesn't exist in my code. Rails 3.2自动需要这些特定于
<%= javascript_include_tag params[:controller] %>
和,在我的代码中没有我知道的事情,并且我已经检查了这一点: <%= javascript_include_tag params[:controller] %>
在我的代码中也不存在。
I want it to stop doing that so that I don't have to arbitrarily create one js
file for every action that I'm not going to use. 我希望它停止这样做,这样我就不必为我不打算使用的每个动作随意创建一个
js
文件。
Is that possible in rails 3.2? 在Rails 3.2中可能吗?
Why rails was loading controller#method
javascript and CSS is because of the line <%= javascript_include_tag params[:controller] %>
which I had removed, but failed to reload my rails server - which was NGINX and I guess it was caching the previous results! Rails为什么要加载
controller#method
javascript和CSS的原因是因为我删除了<%= javascript_include_tag params[:controller] %>
这一行,但未能重新加载我的rails服务器-这是NGINX,我想它正在缓存前一个结果! It fixed it afterwards. 之后将其修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.