I have several pages that using the prototype library, so, I added " javascript_include_tag 'prototype'" in my RoR application. But I want to DRY my code. Is there any way, like a root page, and all view is subclass from this page, that allow me to add this once, and all my view will get the javascript_include_tag 'prototype' automatically? Thank you.
+2
A:
You can add it to the application layout file which is /app/views/layouts/application.html.erb
. All of your view templates will use this layout and therefore include the JavaScript, unless you override with a controller-specific layout or other layout.
- This Rails Guide explains about layouts in more detail.
John Topley
2010-07-09 08:00:43