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 a开发者_StackOverflow中文版cross 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
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.
Yes you can. Using something like Authlogic or Devise is preferred.
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.
精彩评论