NotDan
NotDan

Reputation: 32213

How can I use an application layout in rails for all controllers except a few?

I have an application layout in my rails app to give a default header/footer for my entire website. I have 1 controller that I dont want this to apply to (a checkout page), and an entire namespace that needs to have a separate default template (the admin interface, which has 10-15 different controllers). What is the easiest way to do this?

Upvotes: 1

Views: 187

Answers (2)

fl00r
fl00r

Reputation: 83680

http://apidock.com/rails/ActionController/Layout/ClassMethods/layout

Just create new layout file (ie: /app/views/layouts/new_layout.html.erb) and set it in the beginning of the controller:

layout 'new_layout'

Upvotes: 2

alunny
alunny

Reputation: 900

app/views/layouts/application.html.erb

Will set the default for the entire layout. To override for a specific model, just have

app/views/layouts/mymodel.html.erb

I believe that will work for namespaces also, so long as your layouts directory structure matches your models' directory structure.

Upvotes: 2

Related Questions