Forum: Ruby on Rails Layout question

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.
2dd904ec5981c31e7bb7a5743a53caf8?d=identicon&s=25 Bruce Balmer (brucebalmer)
on 2005-12-02 05:36
(Received via mailing list)
Hi:

If I have four controllers and I want them to use a common layout, I
believe there is a way to do that, I read about it once. To have one
layout that covers all the controllers in an application.

Could someone kindly tell me how that is done?  do you create a
single rhtml file called application. rhtml and drop it at the root
level of the view controller?


bruce
Cee0292fffa691f1fb320d5400200e99?d=identicon&s=25 marcel (Guest)
on 2005-12-02 05:44
(Received via mailing list)
On Thu, Dec 01, 2005 at 09:35:30PM -0700, Bruce Balmer wrote:
> Hi:
>
> If I have four controllers and I want them to use a common layout, I
> believe there is a way to do that, I read about it once. To have one
> layout that covers all the controllers in an application.
>
> Could someone kindly tell me how that is done?  do you create a
> single rhtml file called application. rhtml and drop it at the root
> level of the view controller?

Yes, create a layout called application.rhtml. The conventions for
layouts,
among several, include looking for a layout with the same name as the
current
controller. Then, looking for one called application.rhtml. Put it in
app/views/layouts. If you go off of the naming convention then you must
not
use the "layout" macro in your controller.

marcel
9d1f5d2d9de70bd9a934f557dc95a406?d=identicon&s=25 Daniel ----- (liquid)
on 2005-12-02 05:48
(Received via mailing list)
Hi Bruce,

I think in you ApplicationController

you would put

layout :somelayout

eg

class ApplicationController < ActionController::Base

layout :somelayout

other stuff


end

Cheers
2dd904ec5981c31e7bb7a5743a53caf8?d=identicon&s=25 Bruce Balmer (brucebalmer)
on 2005-12-02 06:12
(Received via mailing list)
The answer - straight from the Agile Web Dev book is:

If you create a layout called application in the layouts directory, it
will be applied to all controllers that donĂ¢??t otherwise have a layout
defined
for them.

bruce
2dd904ec5981c31e7bb7a5743a53caf8?d=identicon&s=25 Bruce Balmer (brucebalmer)
on 2005-12-02 14:33
(Received via mailing list)
Thank you Marcel.
2dd904ec5981c31e7bb7a5743a53caf8?d=identicon&s=25 Bruce Balmer (brucebalmer)
on 2005-12-02 14:37
(Received via mailing list)
The answer - straight from the Agile Web Dev book is:

If you create a layout called application in the layouts directory, it
will be applied to all controllers that donĂ¢??t otherwise have a layout
defined
for them.

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