# Tracking user forum visits?

**URL:** <https://www.ruby-forum.com/t/tracking-user-forum-visits/113300>\
**Category:** Ruby-Forum\
**Created:** [August 29, 2007, 5:49pm UTC](https://www.ruby-forum.com/t/tracking-user-forum-visits/113300 "2007-08-29T17:49:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![combas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/aca169/32.png) [@combas](https://www.ruby-forum.com/u/combas)\
**Post date:** [August 29, 2007, 5:49pm UTC](https://www.ruby-forum.com/t/tracking-user-forum-visits/113300/1 "2007-08-29T17:49:11Z")

</div>

I want to implement the ability to track when users visist forums. So if  
I have two forums each time the user visits them a record will be  
created with the user name, forum id, and date/time. I am new to rails  
and can think of a few ways of doing this, but I’m looking for an  
easy/best practices way and was wondering what other people thought.

thanks,  
-alex

---

<div class="post-metadata">

**Author:** ![combas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/aca169/32.png) [@combas](https://www.ruby-forum.com/u/combas)\
**Post date:** [August 30, 2007, 11:24pm UTC](https://www.ruby-forum.com/t/tracking-user-forum-visits/113300/2 "2007-08-30T23:24:33Z")

</div>

Create a new model “TopicVisits”, with the fields “user\_id”, “forum\_id”  
and “created\_at”. Then add the following code to the end of the method  
ForumController#forum in app/controllers/forum\_controller.rb:  
unless @user.guest?  
TopicVisit.create(:user\_id =\> @user.id, :forum\_id =\> @forum.id)  
end
