Reputation: 953
I am following this guide I have User model.
In ApplicationController:
after_filter :user_activity
private
def user_activity
current_user.try :touch
end
In User model:
def online?
updated_at > 10.minutes.ago
end
How can I access all users that are online? I tried in view:
<%= user.online? %>
I got this error:
undefined local variable or method `user'
Some tips ?
Thanks in advance.
Upvotes: 1
Views: 42
Reputation: 10825
Call User
model <%= User.online %>
and make scope instead of method (or static method):
scope :online, where(:updated_at > 10.minutes.ago)
This is an answer actually (except that you should call User.online
, not online?
which is different method).
Upvotes: 2