jyanks
jyanks

Reputation: 2396

Rails Create Multiple Layouts per-view

In my rails app, I want to render certain pages within a lightbox but the issue is that my main navigation (header/footer, etc) is all included within my application.html.erb layout. I have a ton of pages and the majority of those pages use the navigation. If I remove the navigation from the application.html.erb, I'm going to have to replicate the header and footer code in almost all my view files, save 4-5. How can I specify that I only want certain views to use a different layout, where do I put those layout files and how do I need to name those files?

For reference, this question comes close but doesn't quite answer my question. Rails layouts per action?

I would like to know specifically where those layouts need to be saved and how they need to be named.

Upvotes: 0

Views: 1348

Answers (1)

Nikola
Nikola

Reputation: 704

Put the navigation inside layouts/application.html.erb, so it will be the default layout to render. Put the lightbox code to the layouts/lightbox.html.erb, and for the lightbox pages, add

render :layout => 'lightbox'

to their actions.

Upvotes: 1

Related Questions