Forum: Ruby on Rails sharing layouts between controllers

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
4f0e1e02ac75225794c1f048d8cd37df?d=identicon&s=25 Brett Boge (licinius)
on 2007-07-19 17:59
I have several controllers for doing simple editing of some lists in my
application (like roles, responsibilities, etc), but I want to use the
same layout from my main 'member' controller for everything. How do I
link em up?
6ef8cb7cd7cd58077f0b57e4fa49a969?d=identicon&s=25 Brian Hogan (Guest)
on 2007-07-19 18:33
(Received via mailing list)
If you want every single page in the whole app to use the same layout,
can make one called "application.rhtml" and then you can remove all
layouts and every controller will use that layout by default.

Or you can specify a layout at the controller level

class MyController < ApplicationController

   layout "public"


Or per action

   def list
       render :layout=>"public"

I use application.rhtml as my main layout and then override it in
controllers when I want to change it.
4f0e1e02ac75225794c1f048d8cd37df?d=identicon&s=25 Brett Boge (licinius)
on 2007-07-19 18:35
Brilliant! Thanks, I knew it couldn't be too complicated.
This topic is locked and can not be replied to.