views:

54

answers:

3

Hey all,

I'm very new to RoR, and am trying to implement a user login system. I've got most of it working, but I'm trying to work out how I refer to the logged in user across many different views/controllers etc. Can I store the user in the session? Or is there a better way to do it?

Thanks for reading

+2  A: 

You would more likely store the user id in the session, then get the actual user from somewhere else, like your datastore. That said, there are plugins to do authentication already, and you wouldn't need to worry about any of this if you used one.

x1a4
+1  A: 

Yes you can. Using something like Authlogic or Devise is preferred.

Zepplock
A: 

Since you're a newbie, do checkout Rails Tutorial - http://www.railstutorial.org/book. There's a chapter that covers login/logout/sign up stuffs.

Ed