[英]Ruby on Rails: Devise Users
What can I do to find out if a user is logged in? 如何确定用户是否已登录?
Not only the current user, but all the users who are currently signed in. 不仅当前用户,而且所有当前登录的用户。
Would I have to create my own function or is there an existing rails function that can take care of this? 我是否必须创建自己的函数,或者是否存在可以解决此问题的现有Rails函数?
You could use the devise_lastseenable gem, which would track a timestamp of when the user was last active. 您可以使用devise_lastseenable gem,它可以跟踪用户上一次活动的时间的时间戳。 Then you would write a scope to find all of them within X minutes of the current time.
然后,您将编写一个作用域以在当前时间的X分钟内找到所有这些对象。
Another option would be to track a similar timestamp through sessions, but I'd give this gem a try first. 另一个选择是通过会话跟踪类似的时间戳,但是我会首先尝试一下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.