Forum: Ruby on Rails No layout for specific method

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Daniel W. (Guest)
on 2006-01-10 05:33
(Received via mailing list)
Is there a way to not specify a layout for a particular method in a
controller?
In this particular instance, I am using the admin layout for the login
controller, but I don't want the layout to be used on the "login"
method.

Thanks,

Dan
Jeff C. (Guest)
on 2006-01-10 05:37
Daniel W. wrote:
> Is there a way to not specify a layout for a particular method in a
> controller?
> In this particular instance, I am using the admin layout for the login
> controller, but I don't want the layout to be used on the "login"
> method.


Use this as the last line in your login method:

render :action => "login", :layout => false

This will still cause your login.rhtml to be rendered but without the
surrounding layout.

Jeff
www.softiesonrails.com
Rick O. (Guest)
on 2006-01-10 05:39
(Received via mailing list)
On 1/9/06, Daniel W. <removed_email_address@domain.invalid> wrote:
> Is there a way to not specify a layout for a particular method in a
> controller?
> In this particular instance, I am using the admin layout for the login
> controller, but I don't want the layout to be used on the "login" method.

According to the docs you can do this:

layout nil, :only => :foo

or

layout 'whatever', :except => :foo

http://rails.rubyonrails.com/classes/ActionControl...

--
rick
http://techno-weenie.net
Daniel W. (Guest)
on 2006-01-10 05:51
(Received via mailing list)
Jeff C. wrote:
> Use this as the last line in your login method:
>
Nice!!!! Thanks Jeff.

Dan
Jeff C. (Guest)
on 2006-01-10 05:57
Rick O. wrote:
> layout nil, :only => :foo
>
> or
>
> layout 'whatever', :except => :foo
>
> http://rails.rubyonrails.com/classes/ActionControl...

That's cool, Rick.  I didn't know about the :except option before.

Jeff
www.softiesonrails.com
Daniel W. (Guest)
on 2006-01-10 06:12
(Received via mailing list)
>> Jeff
>> www.softiesonrails.com
>>
>>
>>
> Nice!!!! Thanks Jeff.
>
> Dan
>
Oops!! Spoke to soon. With this I got a double render error.

This worked though.

layout "admin", :except => :login

Dan
This topic is locked and can not be replied to.