Search code examples
ruby-on-railsrubydevise

Check if current devise action and view


I am using the devise gem for authentication in my rails app. I would like to be able to hide my navbar partial if user is on a specific devise action and view. For example if user is currently in devise sessions new, I would like to hide my navbar partial. How would I accomplish this?

Thanks a lot in advance!


Solution

  • You can use devise_controller? helper. Docs

    <%= if devise_controller? %>
      <!-- show partial -->
    <% end %>
    

    If you want to check for specific controller, use request.controller

    <%= if request.controller == 'devise/registrations' %>
      <!-- show partial -->
    <% end %>