Is it too late to put stuff in the head?


I am using layouts and I have one my controller actions include a
javascript tag. Is it possible to get the javascript tag thats part
of the controller’s view .rhtml to be put into the head tag instead
of the body? Or is it to late and I just have to live with having
javascript tags in the body?

Thanks in advance. Scott.

I wrote a very simple plugin for this a while ago.

You can find it at

In your layout:

<%= yield :extra_head_content %> ...

In your view:

<% content_for :extra_head_content do %>
<%= javascript_include_tag ‘whatever’ %>
<% end %>


Scott W.-2 wrote:

Thanks in advance. Scott.

View this message in context:
Sent from the RubyOnRails Users mailing list archive at

Perfect and very elegant!