Using Helper Methods
I finally stumbled upon a nice technique using helper methods as described in the selected answer to the post Rails 3.1 asset pipeline: how to load controller-specific scripts?
The solution described was to add a yield in the layout head section such as:
<%= yield(:head) %>
and call a helper method in the page view:
The helper method in application_helper.rb would look like:
I’m using page caching to speed up my Rails site. Unfortunately this means that I can’t call the helper method shown above in the page view, since the page may be in the cache.
caches_action :index, :layout => false
Calling helper method from the layout
This is what I ended up with in one of my layouts (supports edit views), along with support for CSS:
My helper methods in application_helper.rb looked like: