Rails 3 + Devise: user_signed_in? for another user in the database?

I am creating an application where I want to add online status for a given user.

Do I know that Devise has a user_signed_in method? to check if the user who uses the application is signed or not. But when I try to use it for another user, for example:

user_signed_in?(user)

user.user_signed_in?

I obviously get an undefined method error.

Does Devise have a method for this or should I write my own? One approach was to maintain the online status of a given user in a user model. What is the best solution for this?

+5
source share
3 answers

Devise, , Warden/Devise, , .

is_online User , , -. , last_seen, Devise , . User.online_count , - 5 .

+1

Devise , , . . , , :

if user_signed_in?

, :

if !current_user.nil? && current_user.signed_in

, , : ( )

if user.signed_in?
+18

devise_for :user .rb.

-3

All Articles