Add <%= yield :javascript_includes %>
to application.html.erb
:
<%= javascript_include_tag "application" %>
<%= yield :javascript_includes %>
Add to top of your view.html.erb
:
<% content_for :javascript_includes do %>
<%= javascript_include_tag "forms.js" %>
<% end %>
Notes:
-
forms.js
should be located in theapp/assets/javascripts
directory. - To avoid duplicate inclussion of js files, you must disable the
require_tree
directive inapplication.js
. You just have to remove the equal sign:
// require_tree .
More info about this subject:
Posted by Saul to rails (2013-01-08 23:42)