Ok, so you guys know the drill. I have users they log onto the site. I
need a way to determine which users are currently logged onto the site.
What is the “Rails” way to do this. I am willing to use whatever method
is considered best practice.
I have found this article:
This seems pretty straight forward. Is this essentially the accepted
standard for how to do this?
The gist of it is reading the information out of the sessions column. I
already use sessions and the active_record store so basically it just
@whos_online = Array.new()
onlines = CGI::Session::ActiveRecordStore::Session.find( :all,
:conditions => [ ‘updated_at > ?’, Time.now() - 10.minutes ] )
onlines.each do |online|
id = Marshal.load( Base64.decode64( online.data ) )
@whos_online << User.find(id)
My question is how often is the “updated_at” field updated? Only when I
log in? Do I need to update the field myself before every controller
action? This method requires me to get a list of id’s and then go
through and do a query for the information of every single user.
Basically, I am just curious if this is the smart way and be done with
it or if I am missing something.