downtroden — 2013-01-27T22:47:17-05:00 — #1
I have a main application, does some basic 'core' functions and then everything else is a mountable engine.
What I would like to do is to enclose the engine layout in the application layout. Each engine might have a different layout but I have a base 'frame' for the entire application.
Something like this
application_layout (yields entire layout)
--> engine_layout (yields engine layout with current_action html)
-- --> current_action_view (yields current action html)
I looked at nested layouts on the rails guides site and this seems like it's the answer but it's not working as expected.
Anyone know if what I'm wanting to do is possible?
markbrown4 — 2013-01-28T00:42:49-05:00 — #2
Rails only allows one layout and a view to work out of the box with one yield block. So I believe an engines layout file will disregard the application layout.
If you want to nest you need to use content_for blocks and custom template render calls to do what you want.
Does that help you?
downtroden — 2013-01-28T01:59:47-05:00 — #3
I don't agree with calling this 'nested layouts' as it's not using layouts inside of layouts, it's just using content blocks…*doesn't seem the same.
markbrown4 — 2013-01-28T18:09:46-05:00 — #4
You can explicitly call render 'template.blah' to nest views, you are right that overriding content_for blocks is just switching out parts of the layout.
system — 2014-10-07T23:37:03-04:00 — #5
This topic is now closed. New replies are no longer allowed.