I am using De开发者_如何学Cvise for my users to log into my Ruby on Rails 3.0.9 web application. I'm unfamiliar with how sessions work. They are managed by the browser and not the application right?
I would like to get a list of users who are currently online. And eventually do some kind of background process to automatically update this list.
How would I accomplish this? Is there a gem that would assist?
Thank you,
Andy
One way to do it is have a column last_seen_at
and update that column in your current_user
method:
def current_user
# Stuff...
@current_user.update_attributes(:last_seen_at => DateTime.now)
@current_user
end
Then consider anyone who was last seen in the last 5 minutes as "currently signed in".
精彩评论