1

Possible Duplicate:
Using Rails 3.1, where do you put your “page specific” javascript code?

I have a controller called course store and I wish to include an external js file from a third party only on that page. How can I do this?

Community
  • 1
  • 1
Jonathan Evans
  • 974
  • 2
  • 8
  • 18

2 Answers2

0

Something like this should work...

<%= javascript_include_tag( "http://www.example.com/xmlhr" ) if params[:controller] == 'course_store'  %>
Brad Werth
  • 17,411
  • 10
  • 63
  • 88
0

You can do with content_for,

<% content_for :head do %>
  <%= javascript_include_tag 'admin' %>  
<% end %>

or

<% content_for :head do %>
  <script type="text/javascript">
    $(function() {
      ...
      ...
    });
  </script>
<% end %>

More : http://apidock.com/rails/ActionView/Helpers/CaptureHelper/content_for

Dipak Panchal
  • 5,996
  • 4
  • 32
  • 68