Rails - How to check for online users?
ruby, ruby-on-rails
Solution
The simplest thing would be to add a last_online timestamp to your User model, then define a scope for user called online_now
class User < ActiveRecord::Base
def self.online_now
where("last_online > ?", 15.minutes.ago)
end
end
Problem
What is the best way checking how many users that are current online on a page?