I have a controller where everything uses the same layout except for one action called view. I tried this at the top of the controller: layout "remote", :only => [:view] layout "standard", :except => [:view] This renders standard for :view, and the other actions don't use a layout at all! How can I get what I want here? Thanks!
on 2007-05-02 19:38
on 2007-05-02 19:51
in your action: render [render stuff], :layout => 'layout_name' Jason
on 2007-05-02 20:00
Jason Roelofs wrote: > in your action: > > render [render stuff], :layout => 'layout_name' > > Jason I tried that, but my controller does checking on db stuff, and if it fails, I do a redirect_to, then I get an error about render and redirect_to in the same action.
on 2007-05-02 20:07
In the controller: layout :layout_a, :except => :fred layout :layout_b, :only => fred Michael
on 2007-05-02 20:29
MichaelLatta wrote: > In the controller: > > layout :layout_a, :except => :fred > layout :layout_b, :only => fred > > Michael I tried that too, and got the result I mentioned in my first post. I tried it without giving an array, as well.
on 2007-05-03 04:41
Ugly, but use the method version of layout: layout :standard_or_remote def standard_or_remote(controller) if controller.action_name == 'view' 'remote' else 'standard' end end
on 2007-05-03 06:50
Jason wrote: > You can always put the test in an if/else... b
on 2007-05-03 15:15
> layout :standard_or_remote > def standard_or_remote(controller) > if controller.action_name == 'view' > 'remote' > else > 'standard' > end > end I think that would work great. I decided yesterday to move the view action to a different controller that fit it better logically anyway. Thanks everyone for your help!
on 2007-06-18 20:39
Don't forget: def standard_or_remote(controller) controller.action_name == 'view' ? 'remote' : 'standard' end