Hey all, I have Users and Products, I would like to log every time a user visit a product page. I have: users(id, name) products(id,name) what''s the best way to do this? is it: visits(id,user_id,product_id,visited_on) with user has_many :visits and visit belongs_to :user and product has_many :visits or visits(user_id,product_id,visited_on) with user has_many :visits through products but I''m not sure how to manage that one any idea? thanx in advance Pat --~--~---------~--~----~------------~-------~--~----~ 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 could use a before_filter or after_filter on the product page actions to create a new AR object and save it to the DB. --Jeremy On 12/26/06, Patrick Aljord <patcito-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hey all, > I have Users and Products, I would like to log every time a user visit > a product page. > I have: > users(id, name) > products(id,name) > what''s the best way to do this? is it: > visits(id,user_id,product_id,visited_on) > with user has_many :visits > and visit belongs_to :user > and product has_many :visits > or > > visits(user_id,product_id,visited_on) > with user has_many :visits through products > but I''m not sure how to manage that one > > any idea? > > thanx in advance > > Pat > > > >--~--~---------~--~----~------------~-------~--~----~ 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 12/26/06, Jeremy McAnally <jeremymcanally-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > You could use a before_filter or after_filter on the product page > actions to create a new AR object and save it to the DB. > > --Jeremy >thanx Jeremy but I wanted to know DBwise how to manage visits. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
straightflush-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Dec-26 23:15 UTC
Re: managing visits
sounds like you need a products_users HABTM table with a visits field that you can update on each visit. As jeremy stated, you could handle this in a before_filter or in the actual action for the show product page. On 12/26/06, Patrick Aljord <patcito-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 12/26/06, Jeremy McAnally <jeremymcanally-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > You could use a before_filter or after_filter on the product page > > actions to create a new AR object and save it to the DB. > > > > --Jeremy > > > thanx Jeremy but I wanted to know DBwise how to manage visits. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---