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.
mizage (Guest)
on 2005-12-16 18: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
Frank (Guest)
on 2005-12-16 18:21
(Received via mailing list)
I think all you need to do is:

layout "yourlayout"

on each controller

Frank

----- Original Message -----
From: "mizage" <removed_email_address@domain.invalid>
To: <removed_email_address@domain.invalid>
Sent: Friday, December 16, 2005 11:17 AM
Subject: [Rails] sharing layout code among different controllers
mizage (Guest)
on 2005-12-16 18: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"
Bruce B. (Guest)
on 2005-12-16 18: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.