Forum: Ruby on Rails Is it too late to put stuff in the head?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
317497f11ceba4df9a994ba93cde6e32?d=identicon&s=25 Scott Walter (Guest)
on 2007-04-03 03:11
(Received via mailing list)
Hi,

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.
9d1f5d2d9de70bd9a934f557dc95a406?d=identicon&s=25 Daniel ----- (liquid)
on 2007-04-03 03:47
(Received via mailing list)
I wrote a very simple plugin for this a while ago.

You can find it at
http://agilewebdevelopment.com/plugins/resource_on_demand
Ef0db53920b243d6758c2f6b1306df0d?d=identicon&s=25 Steve Ross (cwd)
on 2007-04-03 04:52
(Received via mailing list)
In your layout:

<head>
<%= yield :extra_head_content %>
</head>
...

In your view:

<% content_for :extra_head_content do %>
<%= javascript_include_tag 'whatever' %>
<% end %>

WDYT?


Scott Walter-2 wrote:
>
> Thanks in advance.  Scott.
>
> >
>
>

--
View this message in context:
http://www.nabble.com/Is-it-too-late-to-put-stuff-...
Sent from the RubyOnRails Users mailing list archive at Nabble.com.
317497f11ceba4df9a994ba93cde6e32?d=identicon&s=25 Scott Walter (Guest)
on 2007-04-03 14:32
(Received via mailing list)
Perfect and very elegant!
This topic is locked and can not be replied to.