Is there a way to return the number of devise users currently logged in?

前端 未结 2 810
清歌不尽
清歌不尽 2021-01-22 09:55

Is there a way to figure out how many users are actively logged into a rails app using devise?

Rails 3.1

gem \'devise\', \'~> 1.4\' gem \'dm

2条回答
  •  -上瘾入骨i
    2021-01-22 10:40

    I wrote a blog post about this. We had to do this at work, and this solution seems to fit our needs.

    You should add last_request_at and logged_in to your user model. last_request_at can be grabbed from the user_session information on the request. Logged_in should be set on sign_in / sign_out.

提交回复
热议问题