I''m new to Rails (and liking it!) and I have multiple controllers, each of which has a method which uses a view template which is identical to what the others use. I would like to be able to have just one template to maintain that they can all use. What is the customary way to do this? I tried using render_action to specify the template explicitly, and it "works". But I would like to be able to redirect to this method without getting a "Can only render or redirect once per action" error. Thanks for any assistance! -Steve Bergman -- Posted via http://www.ruby-forum.com/.
Steve Bergman wrote:> I''m new to Rails (and liking it!) and I have multiple controllers, each > of which has a method which uses a view template which is identical to > what the others use. > > I would like to be able to have just one template to maintain that they > can all use. What is the customary way to do this? I tried using > render_action to specify the template explicitly, and it "works". But I > would like to be able to redirect to this method without getting a "Can > only render or redirect once per action" error. > > Thanks for any assistance! > > -Steve BergmanIsn''t layout in Rails meant for this? aj -- Posted via http://www.ruby-forum.com/.
Use sub-templates http://api.rubyonrails.com/classes/ActionView/Base.html When using the same rhtml for multiple methods in the same controller (or multiple controllers where you''re passing just one object), use partials: http://api.rubyonrails.com/classes/ActionView/Partials.html - dan -- Dan Kohn <mailto:dan@dankohn.com> <http://www.dankohn.com/> <tel:+1-415-233-1000> On Jul 20, 2006, at 6:49 PM, Steve Bergman wrote:> I''m new to Rails (and liking it!) and I have multiple controllers, > each > of which has a method which uses a view template which is identical to > what the others use. > > I would like to be able to have just one template to maintain that > they > can all use. What is the customary way to do this? I tried using > render_action to specify the template explicitly, and it "works". > But I > would like to be able to redirect to this method without getting a > "Can > only render or redirect once per action" error. > > Thanks for any assistance! > > -Steve Bergman > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails