AdamNYC
AdamNYC

Reputation: 20425

Hide content_for for a particular page

I have application.html.haml file that has a navigation top bar. In a particular page, I would like not to use this bar.

How can I tell Rails not to inherit from application.html.haml file?

Thank you.

Upvotes: 1

Views: 155

Answers (2)

sockmonk
sockmonk

Reputation: 4255

In addition to using

render :layout => false

You can also specify an alternate layout:

render :layout => 'no_top_bar_layout'

Or, you can add a conditional to your main layout that checks an instance variable, and skips the top bar part of the layout if that instance variable is set. It's a bit messier than the first two options, but might make sense in some limited situations.

Upvotes: 2

Doon
Doon

Reputation: 20232

you can use :layout => false in the render for the particular controller action.

def page_with_no_layout

  .....

  render :layout => false 

end

Upvotes: 1

Related Questions