Session modify user updated_at

I have a system that uses sessions for users to display their
personalized site. I want to modify the updated_at field in the
database when ever their personal account is viewed. Any ideas?

Thank you,

Sean McGilvray

Personally I’d use a last_visited field instead, since the record wasn’t actually updated.

That said, maybe this will help for what you’re asking to do: http://blog.evanweaver.com/articles/2006/12/26/hacking-activerecords-automatic-timestamps/

How would you implement the last_visited?

Sean McGilvray
Executive Recruiter
Identity Theft Specialist
Pre-Paid Legal Service’s, Inc. NYSE:PPD
Phone: 760-486-1019
smcgilvray@prepaidlegal.com
http://www.transferhome.net

You say you’d like to track when their account was last viewed. Do you mean viewed by the user, or viewed by someone else?

That said, if it’s by the user, update last_visited when the user logs in.

If it’s someone else, update last_visited when the view is loaded to show that user’s information. You could run in to some trouble with that if you start doing page caching, though.

As Sean says, it sounds like you're looking for a field that's
somewhat different to what updated_at is supposed to represent.

To track the visit information, you could add a last_visited datetime
to your model. You would add the code:

@user.update_attribute(:last_visited, Time::now)

to the action that you wanted to record access to. You can also do the
same with the updated_at field if you prefer.

-Matt