I am using activerecord for saving my sessions. I have added a user_id field to my sessions table how can i save the user id to this table once the user logs on for the frist time? CGI::Session::ActiveRecordStore::Session.user_id = current_user.id i am trying the above line but its not working. Any ideas? -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
why do you add a user_id column? thats not the way activeRecordStore works ... all data that you put in a session gets serialized and saved in one column. when the user logs on, you would just do: session[:user_id] = @user.id WITHOUT having a user_id column in the sessions table. Rails handles it for you. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Thorsten L wrote:> why do you add a user_id column? thats not the way activeRecordStore > works ... > > all data that you put in a session gets serialized and saved in one > column. > > when the user logs on, you would just do: > > session[:user_id] = @user.id > > WITHOUT having a user_id column in the sessions table. Rails handles it > for you.ok that works but when i run def isonline for current_session in CGI::Session::ActiveRecordStore::Session.find(:all) if current_session[:user_id] == self.id return true end end return false end i get false back everytime even when i know the user is online -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
don''t know if you have read this article but it should answer your question http://habtm.com/articles/2005/12/15/whos-online Chris On 11/9/06, Stewart <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Thorsten L wrote: > > why do you add a user_id column? thats not the way activeRecordStore > > works ... > > > > all data that you put in a session gets serialized and saved in one > > column. > > > > when the user logs on, you would just do: > > > > session[:user_id] = @user.id > > > > WITHOUT having a user_id column in the sessions table. Rails handles it > > for you. > > ok that works but when i run > > def isonline > for current_session in > CGI::Session::ActiveRecordStore::Session.find(:all) > if current_session[:user_id] == self.id > return true > end > end > return false > end > > i get false back everytime even when i know the user is online > > -- > 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?hl=en -~----------~----~----~----~------~----~------~--~---