Ruby on Rails Thursday, January 19, 2017

Hey David,

Devise has an additional constraint named unauthenticated which you can use to restrict access to routes for a logged in user.

For example,

authenticated :user do
   root 'hub#index', as: :authenticated_root

unauthenticated :user do
   # place routes for unauthenticated users only here
   resources :welcomes

What you'll find is that now if the user tries to navigate to the /welcomes path while logged in, the route will be undefined. 

Documentation is here:

Hope that helps!

On Thursday, January 19, 2017 at 11:56:45 AM UTC-5, David Williams wrote:
The authenticated user root path works perfectly. What I'm trying to do is stop the user from returning back to the root 'welcome#index' after login?

authenticated :user do
root 'hub#index', as: :authenticated_root

# How can I stop users from going back to root 'welcome#index' after they've logged in.

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment