title: Rails: Is it possible to get the controller and action name from an asset file?
body: <p>I want to do something like this in my asset pipeline:</p>
  
  <p>application.js</p>
  
  <pre><code>//= require jquery
  //= require jquery_ujs
  //= require_tree ./includes
  //= require global
  &lt;% if File.exists? "#{Rails.root}/assets/javascripts/#{params[:controller]}.js" %&gt;
      //= require &lt;%= params[:controller] %&gt;
  &lt;% end %&gt;
  &lt;% if File.exists? "#{Rails.root}/assets/javascripts/#{params[:controller]}/#{params[:action]}.js" %&gt;
      //= require &lt;%= params[:controller] %&gt;/&lt;%= params[:action] %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Now this doesn't work because the assets files cannot access <code>params</code> variable. Now is there a way to grab what the current controller action names are from the asset?</p>
  
  <p>Or is the asset file precompiled for the whole project, rending this impossible?</p>