user3814030
user3814030

Reputation: 1283

How can I hide partial views on rails.

In my application.html.erb I am rendering a header and a navbar

<%= render 'layouts/header' %>
<%= render 'layouts/navbar' %>
<%= yield %>

On devise view I want to hide the header and the navbar and display only the login view.

Upvotes: 0

Views: 908

Answers (2)

Richard Peck
Richard Peck

Reputation: 76774

As mentioned by marczking, you could use the devise_controller? command in the application layout, or you could create a totally different layout:

#app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
   layout :auth, if: devise_controller?
end

--

display only the login view

If you only wanted to show the header on login, you may wish to use another devise helper - user_signed_in?:

<% unless user_signed_in? %>
   <%= render 'layouts/header' %>
<% end %>

This would show the header / nav when the user is not signed in.

Upvotes: 1

MMachinegun
MMachinegun

Reputation: 3074

you could check for your devise_controller:

<% unless devise_controller? %>
    <%= render 'layouts/header' %>
    <%= render 'layouts/navbar' %>
<% end %>
<%= yield %>

Upvotes: 5

Related Questions