One layout for entire App?

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

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”

Cool !!

Thanks,
Tuka

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs