New Discussion

Notifications

You’re not receiving notifications from this thread.

Condition if devise action view

3
Gems / Libraries
Hi everyone,

I am struggeling with finding out how to add a condition to hide my navbar partial if user is currently in one of the devise views. For example if user is currently in devise sessions new, I would like to hide my navbar partial. How would I accomplish this?

/ Jacob

I think it is:

<% if devise_controller? %>

Hey Jacob (hah),

The current controller and action are in the params. So in your view, you can do something like:

<% unless params[:controller] == "devise/sessions" && params[:action] == "new" %>
  <!-- show the menu -->
<% end %>

Chris just beat me to the post - so I'll just add that Chris' answer is much better if you just want it applied to all devise controllers - much more concise if you don't need to differentiate between actions.
Thank you so much Chris and Jacob! Problem solved! 
Join the discussion
Create an account Log in

Learning Ruby on Rails? Join our newsletter.

We won't send you spam. Unsubscribe at any time.