Alexey Muranov
2011-Jul-20 12:18 UTC
can :layout option be passed to render a partial for a collection?
Hello, i have read somewhere that calling <%= render :partial => ''my_partial'', :collection => my_collection, :as => :model, :layout => ''my_layout'' %> used to render output of <%= render :partial => ''my_partial'', :collection => my_collection, :as => :model %> inside a single layout ''my_layout''. However, it does not seem to work for me now, and this behavior is not documented in API pages, the suggested way to do is to yield explicitly: <%= render :layout => ''my_layout'' do %> <%= render :partial => ''my_partial'', :collection => my_collection, :as => :model %> <% end %> Can anybody please explain if i am doing something wrong, or if this behavior of :layout option is not supported anymore? Thanks, Alexey. -- Posted via http://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Kendall Gifford
2011-Jul-21 00:44 UTC
Re: can :layout option be passed to render a partial for a collection?
On Wednesday, July 20, 2011 6:18:40 AM UTC-6, Ruby-Forum.com User wrote:> > Hello, > i have read somewhere that calling > > <%= render :partial => ''my_partial'', :collection => my_collection, :as > => :model, :layout => ''my_layout'' %> > > used to render output of > <%= render :partial => ''my_partial'', :collection => my_collection, :as > => :model %> > inside a single layout ''my_layout''. > > However, it does not seem to work for me now, and this behavior is not > documented in API pages, the suggested way to do is to yield explicitly: > > <%= render :layout => ''my_layout'' do %> > <%= render :partial => ''my_partial'', :collection => my_collection, :as > => :model %> > <% end %> > > Can anybody please explain if i am doing something wrong, or if this > behavior of :layout option is not supported anymore? >This :layout option isn''t supported if you''re rendering a collection (I just checked the source code in actionpack-3.0.7/lib/action_view/render/partials.rb, specifically the ActionView::Partials::PartialRenderer#render_collection method) The "Rendering Collections" section of the "Layouts and Rendering in Rails" guide (http://guides.rubyonrails.org/layouts_and_rendering.html#rendering-collections) makes no mention of supporting the :layout option either. It does have support for a :spacer_template option if that helps. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/iDKyaJ2PTykJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Alexey Muranov
2011-Jul-24 20:48 UTC
Re: can :layout option be passed to render a partial for a collection?
Thank you for clarifying this. Alexey. -- Posted via http://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.