显示登录用户的实时列表(可能使用 AuthLogic) [英] Display realtime list of logged in users ( Maybe using AuthLogic)
问题描述
我需要显示当前登录我网站的用户的实时或至少接近实时的列表.
I need to display a real-time or at least near real-time list of users currently logged into my site.
我使用 AuthLogic gem 来管理注册/登录 &会话管理.是否有一种快速的方法可以让我找到使用 authlogic 登录网站的当前用户名列表?
I'm using the AuthLogic gem to manage Registration/Login & Session management. Is there a quick way for me to find a list of current usernames logged into the site using authlogic?
我问这个新问题是因为关于这是否可能存在相互矛盾的答案:
I ask this new question because there seems to be conflicting answers on whether this is possible:
谢谢
推荐答案
好的,我刚刚试过了,下面的代码允许您访问所有登录的用户及其模型属性.
Ok, I just tried it out there and the following code allows you access to all logged in users and their model attributes.
def online_users
return Member.logged_in
end
@loggedIn = online_users
@loggedIn.each do |member|
print member.username
print member.email
end
您必须将 'last_request_at' authlogic 列添加到您的用户表中.
You must add the 'last_request_at' authlogic column to your user table.
这篇关于显示登录用户的实时列表(可能使用 AuthLogic)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!