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/ On Thu, Jun 18, 2009 at 11:32 AM, Sean McGilvray <smcgilvray-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > 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 > > >-- Christopher Warren christopher.warren-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 612.424.9880 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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-C6gt8ZI8z3bIY2DP0bkpxA@public.gmane.org http://www.transferhome.net On Thu, Jun 18, 2009 at 9:55 AM, Christopher Warren < christopher.warren-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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/ > > On Thu, Jun 18, 2009 at 11:32 AM, Sean McGilvray <smcgilvray-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> >> 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 >> >> > > > -- > Christopher Warren > christopher.warren-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > 612.424.9880 > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. On Thu, Jun 18, 2009 at 12:54 PM, Sean McGilvray <smcgilvray-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> 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-C6gt8ZI8z3bIY2DP0bkpxA@public.gmane.org > http://www.transferhome.net > > > On Thu, Jun 18, 2009 at 9:55 AM, Christopher Warren < > christopher.warren-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> 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/ >> >> On Thu, Jun 18, 2009 at 11:32 AM, Sean McGilvray <smcgilvray-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >> >>> >>> 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 >>> >>> >> >> >> -- >> Christopher Warren >> christopher.warren-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >> 612.424.9880 >> >> >> > > > >-- Christopher Warren christopher.warren-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 612.424.9880 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 18, 6:54 pm, Sean McGilvray <smcgilv...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> How would you implement the last_visited?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