Reputation: 13
I am using the Sorcery gem for authentication - is there any way of setting two different roots? I want something like this in my routes.rb file.
if user = logged in
root to: 'users#home'
else
root to: 'users#landing'
end
From what I can tell, there only seems to be methods for doing this when using the Devise gem. Is there a way of using two different roots without using Devise?
Upvotes: 0
Views: 80
Reputation: 211580
The router has no idea what user
is, and nor should it. That's a controller concern. What you might do is have a single endpoint that behaves differently depending on your logged in status. Example:
def home
if (logged_in?)
render(action: 'landing')
end
end
This will render landing
if and only if you're logged in, otherwise home
.
Upvotes: 4