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.

2010/5/14 David Z. [email protected]

application2.html.erb??
.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


tommy xiao
E-mail: xiaods(AT)gmail.com

Hi David,

On Thu, May 13, 2010 at 7:16 PM, David Z.
[email protected]wrote:

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

more guide:

2010/5/14 tommy xiao [email protected]

I don’t want to assign a seperate layout for each of the controllers,
http://groups.google.com/group/rubyonrails-talk?hl=en.


tommy xiao
E-mail: xiaods(AT)gmail.com


tommy xiao
E-mail: xiaods(AT)gmail.com