Is it possible to have to have the root url configured so that the user
is directed to a different page depending if they are logged in or not
whilst also keeping the url the same?
E.g
If the user is logged in, I want www.example.com to show the Users#show
action
If the user is not logged in, I want www.example.com to the the
Sessions#new action
At the moment I have the root url configured to be the Users#show action
and I have a 'login_required' before filter on the Users#show action
which redirects the user to Sessions#new if the user is not logged in.
This works well but the URL is changed when the user is directed and so
all nonlogged in users see www.example.com/login as the url when they
come to the site. I want everybody to see www.example.com regardless of
whether they are logged in or not.
Is it possible to have to have the root url configured so that the user
is directed to a different page depending if they are logged in or not
whilst also keeping the url the same?
E.g
If the user is logged in, I wantwww.example.comto show the Users#show
action
If the user is not logged in, I wantwww.example.comto the the
Sessions#new action
No, its not possible as far I know.
At the moment I have the root url configured to be the Users#show action
and I have a 'login_required' before filter on the Users#show action
which redirects the user to Sessions#new if the user is not logged in.
This works well but the URL is changed when the user is directed and so
all nonlogged in users seewww.example.com/loginas the url when they
come to the site. I want everybody to seewww.example.comregardless of
whether they are logged in or not.
All files under config directory could not access any methods or
variables like 'session'. And it is must to have a different urls for
different actions rendered in the browser.
Still you want to do that?
Use same controller and same action but render a partial based on your
stuff needed.