Inexperienced user needs advice with layouts

I’m thinking that I want three levels of layouts: one level for the
application, one level for each controller, and a third for each action.
The top (application) would define the overall page with the header,
side panels, maybe tabs. The second would define these areas further
like what tabs. And the third would fill in the detailed content.

Rails has two of these with layout and templates by default.

Given that Rails has only two levels, is this really what I want and I’m
just confused thinking I want a third level? It just seems like most of
each of the controller’s layouts will be a lot of duplication.

If not, and a third level is a good idea, are there any suggestions of
how to do it in a “Rails” way?

Thank you for your time,
Perry

I’m thinking that I want three levels of layouts: one level for the
application, one level for each controller, and a third for each action.

You want both a layout and a view for each action? I’m not sure
that
makes much sense to me… why not just merge it all into the view?

As for having a layout per controller, you could have a single master
layout that contained a call such as:

render :partial => “layouts/#{@controller_name}”

or some such…

Philip H. wrote:

I’m thinking that I want three levels of layouts: one level for the
application, one level for each controller, and a third for each action.

You want both a layout and a view for each action? I’m not sure
that
makes much sense to me… why not just merge it all into the view?

I think a better way to think of it is that I want two levels of
layouts, a global layout for the application and then a sub-layout per
controller.

What I came up with so far is that I have the normal layout per
controller but they call application helpers that create most of the top
level layout. The parameters that the per controller layout pass to the
application helpers define the specifics of the layout for that
controller.

That seems to be working o.k. so far.

On 9/25/07, Perry S. [email protected] wrote:

just confused thinking I want a third level? It just seems like most of
each of the controller’s layouts will be a lot of duplication.

If not, and a third level is a good idea, are there any suggestions of
how to do it in a “Rails” way?

You’re not the first to think of this. Here’s a good article:

http://www.marklunds.com/articles/one/360

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