rails layouts

Hey

Right now, I have a lot of controllers/views

Half of them require one type of layout, the other half requires another type of layout.

right now, the first half of my views uses the application.html.erb

Now, there are another bunch of views. How can I assign them all to application2.html.erb??

I don't want to assign a seperate layout for each of the controllers, and application.html.erb is already used. thanks

hi, i know in controller ,use

layout 'application2'
can change default layout.

more guide: http://guides.rubyonrails.org/layouts_and_rendering.html#using-nested-layouts

Hi David,

Hey

Right now, I have a lot of controllers/views

Half of them require one type of layout, the other half requires

another type of layout.

right now, the first half of my views uses the application.html.erb

Now, there are another bunch of views. How can I assign them all to

application2.html.erb??

I don’t want to assign a seperate layout for each of the controllers,

and application.html.erb is already used. thanks

Assuming that your views / layouts are specific to controllers, one way to handle this is to have you controllers inherit from a ‘child’ of ApplicationController Pseudocode follows.

ApplicationControllerForLayoutOne << ApplicationController layout :layout1 end

OneController < ApplicationControllerForLayoutOne end

ApplicationControllerForLayoutTwo << ApplicationController

layout :layout2 end

AnotherController < ApplicationControllerForLayoutTwo end

HTH, Bill