Hi, This is probably a really dumb question but how do you use ''render_component'' so that it doesn''t include the layout? On page 368 of the latest Agile Development with Rails book it says: "There''s a potential trap here: if cart_summary renders using this same template, we''ll end up recursing forever. You''ll want to exclude actions used to render components from layout processing, either using layout "xxx", :except => :cart_summary or by calling render(:layout=>false,...) in the action that creates the component." I''ve tried both of these and yet I still end up with the layout being included in the output. The one thing that may be important is that the controller I''m rendering is nested, i.e. I have: class Foo::BarController < ApplicationController Hmm, maybe I should test it without that ... Matt
Matthew Denner <matt@...> writes:> This is probably a really dumb question but how do you use > ''render_component'' so that it doesn''t include the layout? On page 368 > of the latest Agile Development with Rails book it says: > > "There''s a potential trap here: if cart_summary renders using this same > template, we''ll end up recursing forever. You''ll want to exclude > actions used to render components from layout processing, either using > > layout "xxx", :except => :cart_summary > > or by calling render(:layout=>false,...) in the action that creates the > component." > > I''ve tried both of these and yet I still end up with the layout being > included in the output. The one thing that may be important is that the > controller I''m rendering is nested, i.e. I have: >I have this same problem... calling render_component :controller=>x, :action=>y with :layout => false or :layout => nil still renders the layout for that controller. Is there any way to make it not render the layout ? - steve dp
On Nov 17, 2005, at 10:59 PM, steve dp wrote:> Matthew Denner <matt@...> writes: > >> This is probably a really dumb question but how do you use >> ''render_component'' so that it doesn''t include the layout? On page >> 368 >> of the latest Agile Development with Rails book it says: >> >> "There''s a potential trap here: if cart_summary renders using this >> same >> template, we''ll end up recursing forever. You''ll want to exclude >> actions used to render components from layout processing, either >> using >> >> layout "xxx", :except => :cart_summary >> >> or by calling render(:layout=>false,...) in the action that >> creates the >> component." >> >> I''ve tried both of these and yet I still end up with the layout being >> included in the output. The one thing that may be important is >> that the >> controller I''m rendering is nested, i.e. I have: >> > > I have this same problem... > > calling render_component :controller=>x, :action=>y with :layout => > false or > :layout => nil still renders the layout for that controller. > > Is there any way to make it not render the layout ? > > - steve dpGuys- Here is how I get around this issue: def x if params[:no_layout] do stuff.... render :layout => false else do stuff .... render :layout => "x_tmpl" end end And then you can call the render_component like this: render_component( :controller=>x, :action=>y, :params => {:no_layout => true}) HTH- -Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org