The Asset Pipeline docs suggest how to do controller-specific JS:
For example, if a
ProjectsController
is generated, there will be a new file atapp/assets/javascripts/projects.js.coffee
and another atapp/assets/stylesheets/projects.css.scss
. You should put any JavaScript or CSS unique to a controller inside their respective asset files, as these files can then be loaded just for these controllers with lines such as<%= javascript_include_tag params[:controller] %>
or<%= stylesheet_link_tag params[:controller] %>
.