Hi, 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. Thanks and Regards, Sandeep Kn Reddy -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On Thu, 2006-11-02 at 05:30 +0100, Sandeep Kn Reddy wrote:> Hi, > > 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 %> Craig --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Sandeep Kn Reddy wrote:> Hi, > > 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. > > Thanks and Regards, > Sandeep Kn ReddyAll you need is the session hash # some_controller.rb class SomeController < ApplicationController def set session[:foo] = ''something to remember'' end def show render :text => session[:foo] end end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---