显示登录用户的实时列表(可能使用 AuthLogic) [英] Display realtime list of logged in users ( Maybe using AuthLogic)

查看:41
本文介绍了显示登录用户的实时列表(可能使用 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:

Rails 和 Authlogic.显示当前登录的用户

如何获取在线用户列表授权逻辑?

谢谢

推荐答案

好的,我刚刚试过了,下面的代码允许您访问所有登录的用户及其模型属性.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆