ruby - Multiple Level Nested Layout in Rails 3 -
i have application global application layout file application.html.haml
. have multiple "controller stacks": our main site, our admin portal, , our business site. each of these, controllers within module , inherit same basecontroller
. each stack has it's own layout file. within stack, controllers have layout files well.
i views (unless otherwise specified) render inside multiple levels of nested layouts : application, "stack", "controller".
for example, site::blogcontroller#show
action, i'd rails render:
/site/blog/show.html.haml
inside /layouts/site/blog.html.haml
inside /layouts/site.html.haml
inside /layouts/application.html.haml
i having difficulty understanding how insert /layouts/site.html.haml
stack. appears though automatically, rails render action inside controller layout inside application layout, however, can't see how "insert" layouts render stack.
any appreciated, however, have read rails guides no avail, link http://guides.rubyonrails.org/layouts_and_rendering.html#using-nested-layouts not helpful.
i reread link posted ( http://guides.rubyonrails.org/layouts_and_rendering.html#using-nested-layouts ) , realized missed key detail.
<%= render :file => 'layouts/application' %>
so, in site::basecontroller
have call layout 'site'
, in /layouts/site.html.haml
have
= content_for :footer -#content footer = render :file => 'layouts/application'
then in site::blogcontroller
extends site::basecontroller
have layout 'site/blog'
, in /layouts/site/blog.html.haml
have
=content_for :header %h1 hello world! = render :file => 'layouts/site'
this renders layouts nested described in question. sorry missing in question. should've read closer.
Comments
Post a Comment