Question- if I have more then one view I wish to display in a layout , how do I tell content_for_layout what to display and where ? TIA Stuart -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060713/a2d0a8c8/attachment.html
Stuart, In your application.rhtml use <%= yield %> to display your view. If you wish to display another portion of that view somewhere else in the layout do this: --- [ your view ] --- my main view content... <% content_for("nav") do -%> my nav stuff <% end -%> --- [ application.rhtml ] --- <%= yield :nav %> Hope this helps, Zack On 7/13/06, Dark Ambient <sambient@gmail.com> wrote:> Question- if I have more then one view I wish to display in a layout , how > do I tell content_for_layout what to display and where ? > > TIA > Stuart > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
On Thu, 13 Jul 2006, Dark Ambient wrote:> Question- if I have more then one view I wish to display in a layout , how > do I tell content_for_layout what to display and where ?content_for_layout is deprecated (in favor of yield [1]), but the principles are the same either way. Your layout should only have one yield in it, where the content goes. As for the rest, have your main view render one or more partials (my layouts typically render partials for the various pieces of the page). [1] http://weblog.rubyonrails.com/2006/04/25/use-params-not-params/ -- _Deirdre web / blog: http://deirdre.net/ "Memes are a hoax! Pass it on!"
Deirdre Saoirse Moen wrote on 13.07.2006 22:42:> On Thu, 13 Jul 2006, Dark Ambient wrote: > >> Question- if I have more then one view I wish to display in a layout , how >> do I tell content_for_layout what to display and where ? > > content_for_layout is deprecated (in favor of yield [1]), but theWhat else is deprecated? It''s really strange to say that something from a stable release is deprecated when it isn''t marked as deprecated and there is no replacement documented, isn''t it?
On Fri, 14 Jul 2006, Markus Kolb wrote:> Deirdre Saoirse Moen wrote on 13.07.2006 22:42: > > On Thu, 13 Jul 2006, Dark Ambient wrote: > > > >> Question- if I have more then one view I wish to display in a layout , how > >> do I tell content_for_layout what to display and where ? > > > > content_for_layout is deprecated (in favor of yield [1]), but the > > What else is deprecated? It''s really strange to say that something from > a stable release is deprecated when it isn''t marked as deprecated and > there is no replacement documented, isn''t it?It is documented. Did you see the link I also pasted?
Yeah, I''m getting used to the sort of documentation :). It would be better perhaps if there was a page that listed all that is deprecated. If I''m using IRB or Scite in a straight Ruby environment that Ruby will tell it''s deprecated. Not sure how that all works in Rails and where to look for Rails generated code feedback. Stuart On 7/13/06, Deirdre Saoirse Moen <deirdre@deirdre.net> wrote:> > On Fri, 14 Jul 2006, Markus Kolb wrote: > > > Deirdre Saoirse Moen wrote on 13.07.2006 22:42: > > > On Thu, 13 Jul 2006, Dark Ambient wrote: > > > > > >> Question- if I have more then one view I wish to display in a layout > , how > > >> do I tell content_for_layout what to display and where ? > > > > > > content_for_layout is deprecated (in favor of yield [1]), but the > > > > What else is deprecated? It''s really strange to say that something from > > a stable release is deprecated when it isn''t marked as deprecated and > > there is no replacement documented, isn''t it? > > It is documented. Did you see the link I also pasted? > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060714/606337ef/attachment.html
Deirdre Saoirse Moen wrote on 14.07.2006 01:16:> On Fri, 14 Jul 2006, Markus Kolb wrote: > >> Deirdre Saoirse Moen wrote on 13.07.2006 22:42: >>> On Thu, 13 Jul 2006, Dark Ambient wrote: >>> >>>> Question- if I have more then one view I wish to display in a layout , how >>>> do I tell content_for_layout what to display and where ? >>> content_for_layout is deprecated (in favor of yield [1]), but the >> What else is deprecated? It''s really strange to say that something from >> a stable release is deprecated when it isn''t marked as deprecated and >> there is no replacement documented, isn''t it? > > It is documented. Did you see the link I also pasted?The link? That''s a comment thread about the yield stuff but no documentation. The API of stable Rails is documentation and it says to use content_for_layout. The API of edge has changed and it says yield. So you have to say that content_for_layout will be deprecated in the future but it is the supported thing for stable Rails, isn''t it?