I'm developing a site with a Login on the frontpage, so when you
logged in you will see
another "thing" than if you are not logged in.
For Example you will see some explanations about the site if you are a
visitor, but if you are logged in
you will some things specific for you and i want to show that on the
frontpage e.g. example.com.
How can I handle that? I'm using Authlogic für Session handling and
Login.
My Idea is a session based Routing, but I don't know how that can be
done?
As far as I know, that's not possible. One option would be for the
controller receiving that action to render entirely different
templates based on whether the user is logged in:
class HomeController
def show
if current_user
render :action => 'show_logged_in'
else
render :action => 'show'
end
end
end
Note that the 'show_logged_in' action doesn't actually need to exist;
the name of the option is a bit misleading here.
Note also that the "else" statement isn't necessary; I just included
it here for clarity.
The normal way to do this is to handle it at the controller level in a
before filter set in the ApplicationController, used to check that the
user is logged in, via the session, and/or a token, and or via basic
http authentication depending on the requirements of the application,
and redirects to the login url if not.
And how does twitter is doing that?
There is no Redirect to something, when i visit the Root URL As
a visitor and with à Session the Main Page is my tweetlist.