The problem you've run into is that yield blocks have to be filled before they are called - normally, with the yields in the layout, everything else from the request will render first. But since you're calling content_for in the layout, things aren't working.
The quickest way to do what you're trying would be to put the html part in a content_for block, and then call the partial from the header (with a yield :menu_body where the current partial is). That puts the blocks into the correct order. --Matt Jones On Feb 6, 11:00 am, Stephen <sblackst...@gmail.com> wrote: > Has Anyone found a solution to this? My setup is like this > > layout (pseudo-code) > > <html> > <head> > <%= yield : head %> > </head> > <body> > <%= render :partial => 'home/menu' %> > <%= yield %> > </body> > </html> > > In my partial I have: > > <% content_for :head do %> > <script>someJavaSCript</script> > <% end %> > Some Html blah blah.. > > And it is not rendering the content into my header thats defined in the > partial thats rendered in the layout. I'm using some of the YUI stuff and > I'm bundling the javascript and the html in the same file so it stays > together nice and neat. > > Regards, > Stephen Blackstone > > On Mon, Jan 26, 2009 at 11:21 AM, Jo Da > <rails-mailing-l...@andreas-s.net>wrote: > > > > > I've the same problem with content_for and yield. The contect of the > > content_for is not inserted in the yeld tag of the layout. > > > I've upgraded from rails 2.1.2 to 2.2.2. > > > In the view > > <% content_for :footer do %> > > footer text here > > <% end %> > > > In the Layout > > > <%= yield :footer %> > > > Anyone know what the problem is? > > -- > > Posted viahttp://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---