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! -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jason Roelofs
2007-May-02 17:50 UTC
Re: Using a different layout for just one action in controller
in your action: render [render stuff], :layout => ''layout_name'' Jason On 5/2/07, Jason <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > 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! > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jason Roelofs wrote:> in your action: > > render [render stuff], :layout => ''layout_name'' > > JasonI 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. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
MichaelLatta
2007-May-02 18:06 UTC
Re: Using a different layout for just one action in controller
In the controller: layout :layout_a, :except => :fred layout :layout_b, :only => fred Michael On May 2, 10:38 am, Jason <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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! > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
MichaelLatta wrote:> In the controller: > > layout :layout_a, :except => :fred > layout :layout_b, :only => fred > > MichaelI tried that too, and got the result I mentioned in my first post. I tried it without giving an array, as well. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
eden li
2007-May-03 02:40 UTC
Re: Using a different layout for just one action in controll
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 May 3, 2:29 am, Jason <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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. > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ben Munat
2007-May-03 04:41 UTC
Re: Using a different layout for just one action in controll
Jason wrote:> 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. >You can always put the test in an if/else... b --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> layout :standard_or_remote > def standard_or_remote(controller) > if controller.action_name == ''view'' > ''remote'' > else > ''standard'' > end > endI 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! -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Don''t forget: def standard_or_remote(controller) controller.action_name == ''view'' ? ''remote'' : ''standard'' end --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---