Forum: Ruby on Rails Page view count

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
7f67063a3700c8f13ddaf7d84c2121c2?d=identicon&s=25 Tyche (Guest)
on 2007-06-09 08:47
(Received via mailing list)
I am new to RoR and and web designing. I want to display page view
count on my home page. How do I do that?

Many thanks,
9338c9a8ebddbcd4035280e6d0d52c31?d=identicon&s=25 James Brooks (Guest)
on 2007-06-09 11:26
(Received via mailing list)

Here's what you _could_ do, you could create a PageHit model which might
contain: request_uri and created_at. Every time a page is viewed, add a
one of these objects. To ensure they are for page views, you could add
for this to the top of your layouts (application.rhtml in layouts, or
whatever layouts your using).

ie, in application.rhtml
<% PageHit.create :request_uri => request.request_uri %>

E3b1a696613226cc5ecc828f0bda900c?d=identicon&s=25 vanquisher (Guest)
on 2007-06-10 07:24
(Received via mailing list)
This looks straight forward. But, this is only increase the load on
the DB.
Everytime a URL is requested, we create transcations on DB.

Is there a better way of doing this?

Another way, as far as I understand is creating a pattern in the logs
and parse it to get the hit or view count.
But, we can run the parser only periodically....making it non-real

Does anyone have a better way or suggest a plugin????
This topic is locked and can not be replied to.