I’m sure this is very simple but i just can’t figure it out.
I have profiles and each time a user visits a profile, the visit is
recorded in the following model…
user_id #the id of the user who is visiting the profile
profile_user_id #the id of the user who is being visited
This is what I am trying to do (in sudo code)
Find all the visitors for a particular profile only returning each
visitor once and order the whole list by viewed_at
This would be an example list…
Mike, 1 min ago
Scott, 2 mins ago
Andy, 3 mins ago
This is what I have do far…
@latest_visitors = ProfileView.find(:all, :conditions =>
[“profile_user_id = ?”, params[:id]], :order => ‘viewed_at DESC’, :limit
=> 5, :group => ‘user_id’)
This returns something along the line of what I want - it returns only 1
record for each user, but it returns the very first time that user
visited the profile.
Any ideas what I’m doing wrong?