views:

15

answers:

0

Here is the situation, I use jquery for everything in my rails app with the exception of a certain action in a certain controller where I need to use prototype (for a graph gem) AND jquery for evreything else. this causes the $ conflict, which I resolve by using the jQuery.noConflict and assign $j for jquery and use $ for prototype. There are also common javascript across the application where I need to change the jquery $ to $j for this particular action, so in my main layout files I do the following. The problem is that the base.js is generated just once in production and by the time the user gets to the show action on graphs controller the base.js only contains the common.js (not common_alt.js with var $j = jQuery.noConflict();), which breaks everything.

Is there a better solution to this, this all seems kinda ugly.

<% if controller.controller_name == 'graphs' && controller.action_name == 'show' %>
  <%= javascript_include_tag 'common_alt.js',  'swfobject.js', :cache => 'base' %>
<% else %>
  <%= javascript_include_tag 'common.js', 'application.js', :cache => 'base' %>
<% end  %>