Skip to content

Instantly share code, notes, and snippets.

@jerodsanto
Created May 6, 2011 18:44
Show Gist options
  • Save jerodsanto/959524 to your computer and use it in GitHub Desktop.
Save jerodsanto/959524 to your computer and use it in GitHub Desktop.
def online_users(since = 5)
sessions = ActiveRecord::SessionStore::Session.where("updated_at >= ?", since.minutes.ago)
user_ids = sessions.all.map { |session| session.data["user_id"] }
User.where(:id => user_ids)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment