Suppose Users are spending long time in the web-site.
How can I obtain user's last active time.
Last active time means the last timestamp of user who requested(accessed to the page. user even doesn't need to update or create new record) to app.
A User might have signed in about an hour ago. Then he's still web surfing in my web site. I want the time of last request the user sent.
Is it possible?
Devise has current_sign_in_at but not last active time.
The way I would implement this is to add a last_active_at
datetime column to the User model, then putting something in my controller:
class ApplicationController
before_filter :record_user_activity
private
def record_user_activity
if current_user
current_user.touch :last_active_at
end
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With