Using Devise on Rails, is there some way to list all the users who currently have active sessions i.e. the users that are currently logged in?
Ps. I'm looking for a robust solution, not something simplistic like the ones in this question
Simply add after_filter in ApplicationController
after_filter :user_activity
private
def user_activity
current_user.try :touch
end
Then in user model add online? method
def online?
updated_at > 10.minutes.ago
end
Also u can create scope
scope :online, lambda{ where("updated_at > ?", 10.minutes.ago) }