One layout for entire App?


#1

Hi,

Being true to DRY, I know in Rails it is possible to define a single
layout associated to a controller and all associated views, lists etc…
by the layout name taking on the name of the controller but is it
possible of a layout to be shared between many controllers ?

TIA,
Tuka

PS: I accidentally posted this in the Test forum… so I moved it here to
get a pertinent reply


#2

Tuka O. wrote:

is it
possible of a layout to be shared between many controllers ?

Yes. Say your ‘shared’ layout is ‘app/views/layouts/foo.rhtml’, just do
this at the top of your controller:

class BarController < ApplicationController
layout “foo”


#3

Cool !!

Thanks,
Tuka


#4

Hi Tuka,

alternatively, you can call your default layout ‘application.rhtml’ - in
this case you do not even need to specify it in application.rb.

Cheers,
Peter