devise_sociable¶ ↑
This gem adds the ability to see who’s currently online to devise. You can use it with server side or cookie based sessions.
Usage¶ ↑
If you use server side sessions and have that setup, there is no migration needed.
If you use cookie sessions (this is the Rails default):
rails g devise_sociable rake db:migrate
In your model, add :sociable:
class User < ActiveRecord::Base devise ..., :sociable end
Then you have access to
User.actives(10.minutes) #everybody who has been active and not logged off in the last 10 minutes User.actives(10.minutes.ago) user.active?(1.hour) #has this user been active and not logged off in the last hour user.active?(1.hour.ago) User.cache_actives(30.minutes) #fill a cache with all active users. use an outside scheduler like ::whenever:: to refresh.
This is pretty experimental, but I think it ought to work.
Thanks to¶ ↑
Thanks to devise_lastseenable which led me down the path of creating this gem.
Copyright¶ ↑
Copyright © 2013 beno. See LICENSE.txt for further details.