Guest User

Untitled

a guest
Apr 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. # This will give you a list of sessions that were last updated within the last 10 minutes, and have user id's
  2. #
  3. # All thats left is to make a before filter and touch on the session data in some way so it gets updated in the db.
  4.  
  5. sessions = CGI::Session::ActiveRecordStore::Session.find(:all, :conditions => {:updated_at => (Time.now-10.minutes..Time.now) } )
  6.  
  7. uids = sessions.collect{|session| session.data[:user]}.compact.uniq
  8.  
  9. active_users = User.find(uids).collect(&:username)
Add Comment
Please, Sign In to add comment