Layout question

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

On Thu, Dec 01, 2005 at 09:35:30PM -0700, Bruce B. 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

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

Thank you Marcel.

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

Hi Bruce,

I think in you ApplicationController

you would put

layout :somelayout

eg

class ApplicationController < ActionController::Base

layout :somelayout

other stuff

end

Cheers