How to show Number of Views (like : This link/page has been viewed 68 times) in rails? I sthere any gem or plugin available for it ?
views:
100answers:
2
+1
A:
Simply add a counter column to your Model, and increment it whenever the page is hit in the controller. As simple as this is, there are some design issues:
Page caching will affect your stats. In this case, you can still use Ajax on your page to register the hit. (Not much different than how google analytics works.)
Do your pages already have an obvious relationship to a Model? If they are user profile pages for example, put the counter in the Profile model.
Walt Gordon Jones
2009-05-04 16:38:23