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 =).
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 Skjerning - http://mentalized.net
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 Skjerning <jakob@mentalized.net>:> > 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 Skjerning - http://mentalized.net > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
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. -- Jakob Skjerning - http://mentalized.net
2006/1/22, Jakob L. Skjerning <jakob@mentalized.net>:> 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. >To make the code look nicer, you can also just use render :layout => ''simple''. Which renders the current action with the ''simple'' layout. -- Michiel Sikkes michiel.sikkes@gmail.com
Thanks for all the quick and usefull answers! I got it working fine now, thanks again. 2006/1/22, Michiel Sikkes <michiel.sikkes@gmail.com>:> 2006/1/22, Jakob L. Skjerning <jakob@mentalized.net>: > > 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. > > > To make the code look nicer, you can also just use render :layout => > ''simple''. Which renders the current action with the ''simple'' layout. > > -- > Michiel Sikkes > michiel.sikkes@gmail.com > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
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 -- Posted via http://www.ruby-forum.com/.