Forum: Ruby on Rails How to include & combine all controller specific javascript in rails?

6d31b173ffdfbe37ae3c6f70afcd7a49?d=identicon&s=25 deepak (Guest)
on 2013-07-30 15:43
(Received via mailing list)
Originally posted
here<http://stackoverflow.com/questions/17948417/how-to...

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
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.