On Thu, 2006-11-02 at 05:30 +0100, Sandeep Kn Reddy wrote:
I need to know, how session tracking is done in RoR. Instead of just one
password. Suppose a person “A” logs in I should be able to load his data
from data base and a person “B” logs in I should be able to load and
display his data etc.
How to do this one?? Please guide me or show me necessary links so that
I can proceed.
I think the common usage is to have a ‘users’ table to store the user
information and you only need to store the user_id in session to be able
to access the appropriate user information.
i.e. after login (depending upon how you authenticate, etc.)…
session[:user_id] = User.id
then at any point…
@name = User.find(session[:user_id]).name
@address = User.find(session[:user_id]).address
or @user = User.find(session[:user_id])
then perhaps in a view…
<%= @user.name %>
<%= @user.address %>