Module: Devise::Models::Stalkable

Defined in:
lib/devise/models/stalkable.rb

Instance Method Summary collapse

Instance Method Details

#mark_last_seen!(login_record_id) ⇒ Object

Marks the time when the user was last seen in the system on a given login record ID.

Parameters:

  • login_record_id (Fixnum, String)

    ID of login record.



22
23
24
25
# File 'lib/devise/models/stalkable.rb', line 22

def mark_last_seen!()
   = .find()
  .update_column :last_seen_at, Time.now
end

#mark_login!(request) ⇒ UserLogin

Creates a new login record based on information in provided request object. Marks the last seen time as well.

to login

Parameters:

  • request (ActionDispatch::Request)

    HTTP request which was used

Returns:

  • (UserLogin)


14
15
16
# File 'lib/devise/models/stalkable.rb', line 14

def mark_login!(request)
  .create((request))
end

#mark_logout!(login_record_id) ⇒ Object

Marks the time when user has logged out on given login record ID. Marks the last seen time as well.

Parameters:

  • login_record_id (Fixnum, String)

    ID of login record.



31
32
33
34
35
36
# File 'lib/devise/models/stalkable.rb', line 31

def mark_logout!()
   = .find()
  t = Time.now
  .update_column :last_seen_at, t
  .update_column :signed_out_at, t
end