Forum: Ruby on Rails *Very* basic layout question

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.
Santiago Hirschfeld (Guest)
on 2006-01-22 16:44
(Received via mailing list)
I'm trying to use a different layout for just one action in my
controller, all the other actions use the application.rhtml layout, so
what i'm doing is ...

class SomeController < ApplicationController
    layout "simple", :only=> :some_action

    ......

end

and the "simple" layout is applied to all the actions, can someone
please give me a hint?

Thanks for everything. I'm loving rails so far, loving the comunity =).
Jakob S. (Guest)
on 2006-01-22 17:27
(Received via mailing list)
On Jan 22, 2006, at 15:43, Santiago Hirschfeld wrote:

> I'm trying to use a different layout for just one action in my
> controller, all the other actions use the application.rhtml layout,

I'm not sure why what you already have doesn't work, but instead just
do render(:action => 'some_action', :layout => 'simple') in your action.

--
Jakob S. - http://mentalized.net
Santiago Hirschfeld (Guest)
on 2006-01-22 17:39
(Received via mailing list)
Thanks, I did

def some_action
  .....
  render(:action => 'some_action', :layout => 'simple')
end

And it worked fine, but i wonder if there is right to render an action
from the same action =) sorry for another stupid question, but I'm
curious.

Thank you for, very much.


2006/1/22, Jakob S. <removed_email_address@domain.invalid>:
Jakob L. Skjerning (Guest)
on 2006-01-22 18:22
(Received via mailing list)
Santiago Hirschfeld wrote:
> Thanks, I did
>
> def some_action
>   .....
>   render(:action => 'some_action', :layout => 'simple')
> end
>
> And it worked fine, but i wonder if there is right to render an action
> from the same action =) sorry for another stupid question, but I'm
> curious.

Yeah, it's fine this way. Basically, Rails will do just that for you if
you don't yourself. Doing it yourself just gives you a bit more control
- and code.
Michiel S. (Guest)
on 2006-01-22 18:52
(Received via mailing list)
2006/1/22, Jakob L. Skjerning <removed_email_address@domain.invalid>:
> > curious.
>
> Yeah, it's fine this way. Basically, Rails will do just that for you if
> you don't yourself. Doing it yourself just gives you a bit more control
> - and code.
>
To make the code look nicer, you can also just use render :layout =>
'simple'. Which renders the current action with the 'simple' layout.
Santiago Hirschfeld (Guest)
on 2006-01-22 19:01
(Received via mailing list)
Thanks for all the quick and usefull answers!

I got it working fine now, thanks again.

2006/1/22, Michiel S. <removed_email_address@domain.invalid>:
csn (Guest)
on 2006-01-30 08:29
If I have in application_controller.rb:

layout 'standard'

and in some_controller.rb

layout 'special', :only=>[:a, :b, :c]

All other actions in some_controller will use NO template at all, rather
than using the 'standard' layout specified in application.rb. Actions
not in :only, or in :except should inherit application.rb's layout IMO.

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