Search code examples
javascriptruby-on-railsruby-on-rails-3.2rails-assets

Stop rails from looking for controller specific JS and CSS


I'm using Rails 3.2 (old and unsupported, I know). It's a legacy application upgrade, and we didn't have controller specific js/css files previously, we have a different structure for them.

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.

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. 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.

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.

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.

Is that possible in rails 3.2?


Solution

  • 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! It fixed it afterwards.