ruby-on-railsdeviseroutesruby-on-rails-5omniauth-facebook

Rails Devise redirecting authenticated user to a specific path


Problem

With Devise the user should be redirected to the edit_user_registration_path of the Devise controller registrations#edit action when already logged in.

Description

In the routes.rb the root is set as root :to => 'main#welcome'. The User is allways redirected to this page, even when already logged in.

Thanks a lot Fabrizio


Solution

  • Maybe what you are looking for is a way to redirect the user to some place after he logs in. This should do it. Put this in app/controllers/application_controller.rb and place in the path you want to take the user to

      def after_sign_in_path_for(resource)
        edit_user_registration_path # or any other path needed
      end