Session based Routing

Hi,

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?

greetings

On Thu, Feb 11, 2010 at 08:23, LeonS [email protected]
wrote:

Login.

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.

Mat

On Thu, Feb 11, 2010 at 7:23 AM, LeonS [email protected]
wrote:

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.

Something like:

<%= render partial => session[:user_id] ? ‘logged_in’ : ‘something_else’
%>


Greg D.
destiney.com | gregdonald.com

On Thu, Feb 11, 2010 at 11:56 AM, Greg D. [email protected] wrote:

On Thu, Feb 11, 2010 at 7:23 AM, LeonS [email protected] wrote:

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.

Something like:

<%= render partial => session[:user_id] ? ‘logged_in’ : ‘something_else’ %>

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.


Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

On Fri, Feb 12, 2010 at 08:03, LeonS [email protected]
wrote:

On Thu, Feb 11, 2010 at 7:23 AM, LeonS [email protected] wrote:
user is logged in, via thesession, and/or a token, and or via basic


You received this message because you are subscribed to the Google G. “Ruby on Rails: Talk” group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Same action, different views.

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs