Forum: Ruby on Rails sharing layout code among different controllers

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.
74bdb7628960d0bc1cc62647cd105eca?d=identicon&s=25 mizage (Guest)
on 2005-12-16 17:17
I want to have one layout for my whole application. The app
has multiple controllers. Is it true that layouts are associated
w/ one controller?
thanks, etienne
33478bbfbd0e2bf2737eca60a555af76?d=identicon&s=25 Frank (Guest)
on 2005-12-16 17:21
(Received via mailing list)
I think all you need to do is:

layout "yourlayout"

on each controller

Frank

----- Original Message -----
From: "mizage" <estettler@mail.com>
To: <rails@lists.rubyonrails.org>
Sent: Friday, December 16, 2005 11:17 AM
Subject: [Rails] sharing layout code among different controllers
74bdb7628960d0bc1cc62647cd105eca?d=identicon&s=25 mizage (Guest)
on 2005-12-16 17:26
ok just found the solution. According to the agile web dev book it says
"If you create a layout call 'application' in the 'layouts' directory,
it will be applied to all controllers that don't otherwise have a layout
defined for them"
2dd904ec5981c31e7bb7a5743a53caf8?d=identicon&s=25 Bruce Balmer (brucebalmer)
on 2005-12-16 17:54
(Received via mailing list)
Yes. But there is a solution.  Make a layout called application.rhtml
and drop it in the root of the layouts folder.  Your app always
checks for the existence of that file.  There is a potential gotcha
here.  If you also have a controller specific layout (made
automatically by scaffolding) it will OVERRIDE the application.rhtml
file.

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