Forum: Ruby on Rails One layout for entire App ?

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.
Tuka O. (Guest)
on 2006-05-03 15:10
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
Craig Mason (Guest)
on 2006-05-03 15:15
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"
Tuka O. (Guest)
on 2006-05-03 15:25
Cool !!

Thanks,
Tuka
Peter S. (Guest)
on 2006-05-03 21:07
(Received via mailing list)
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
This topic is locked and can not be replied to.