Reputation: 43
I'm rendering a header universally across my application in layouts/application.html.erb.
I'd like to make the header not appear in a specific foo.html.erb file.
What's the syntax for un-rendering a universal layout?
EDIT:
The controller for the layout is a devise controller, specifically Sessions Controller.
Upvotes: 4
Views: 2117
Reputation: 20614
in your controller you can set the layout to false (or another layout), if false then you need all of the html,head,body tags in your view file
class BarController < ApplicationController
def foo
render :layout => false # render foo.html.erb with no layout
end
end
see section 2.2.11.2 from the rails guides: http://guides.rubyonrails.org/layouts_and_rendering.html
EDIT: including devise layout overrides
in config/initializers/devise.rb
Devise::SessionsController.layout "bar"
Devise::RegistrationsController.layout "foo"
Devise::ConfirmationsController.layout false # never tried this, guessing it would work
Devise::UnlocksController.layout "bar"
Devise::PasswordsController.layout "foo"
also see the wiki post - https://github.com/plataformatec/devise/wiki/How-To:-Create-custom-layouts has at least one other way
Upvotes: 3
Reputation: 8892
Let's say the controller and action that renders the template foo.html.erb is 'things#foo' and the path to this action is things_path. You can wrap the header in conditional tags as follows
<% unless request.path == things_path %>
<% end %>
. There are several ways to achieve this, but here is one.
Upvotes: 1