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
end

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

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
end

# 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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7629f4cc-24d7-41db-8add-ad9f615a44af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment