Search code examples
ruby-on-railsdevise

DEVISE: Custom redirect when no users are logged in


Currently devise is always redirecting me to /users/sign_in when no session is available. I want to change that redirect to a custom route, for example /home. Is this possible?


Solution

  • Yes .It is possible. Change the line in application.html.erb file in app/view/layouts from

         <%= link_to "Login", new_user_session_path, :class => 'navbar-link'  %>
    

    to

    <%= link_to "Login", your_custom_path, :class => 'navbar-link'  %>