How to include & combine all controller specific javascript in rails?

Originally posted
herehttp://stackoverflow.com/questions/17948417/how-to-include-combine-all-controller-specific-javascript-in-rails

I am using Rails 3.2.1 where I have to include few controller and action
specific javascripts which I am doing using a
javascript_template_manager.html.haml and calling this at the bottom of
the
page. Now I want to combine all these js into one to reduce the http
request. I am using asset pipeline.

How can I combine controller specific js into one precompiled file?

Here is how my _javascript_template_manager.html.haml file looks like:

%noscript
:css
#container{ display:none; }
= render :partial => “/widgets/common/javascript_disabled”

= jquery_include_tag :google = javascript_include_tag “common”
/ condetional javascripts for the app- if params[:controller] ==
“settings”
= javascript_include_tag “plugins/jQuery-cookie”

  • if params[:controller] != “people” and params[:controller] !=
    “companies”
    = javascript_include_tag “plugins/iphone-style-checkboxes”
  • if params[:controller] == ‘users’ || params[:controller] ==
    ‘companies’
    = javascript_include_tag “plugins/best_in_place”
  • if params[:controller] == ‘letters’ || params[:controller] ==
    ‘companies’
    = javascript_include_tag “plugins/jquery.autoSuggest”
  • if params[:controller] == ‘people’ || params[:controller] == ‘letters’
    || params[:controller] == ‘users’ || params[:controller] == ‘companies’
    = javascript_include_tag “plugins/areacomplete”
    = javascript_include_tag “application”

Now I want to combine all the above javascript files into one or what is
the best way to do it?

  • deepak