# Counting number of views on a image

**URL:** <https://www.ruby-forum.com/t/counting-number-of-views-on-a-image/141626>\
**Category:** Rails\
**Created:** [June 27, 2008, 10:38pm UTC](https://www.ruby-forum.com/t/counting-number-of-views-on-a-image/141626 "2008-06-27T22:38:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nishi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@nishi](https://www.ruby-forum.com/u/nishi)\
**Post date:** [June 27, 2008, 10:38pm UTC](https://www.ruby-forum.com/t/counting-number-of-views-on-a-image/141626/1 "2008-06-27T22:38:25Z")

</div>

Can anyone suggest me how to calculate the number of views on a  
particular image (which stored in a blob at database)?

---

<div class="post-metadata">

**Author:** ![nishi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@nishi](https://www.ruby-forum.com/u/nishi)\
**Post date:** [June 27, 2008, 10:46pm UTC](https://www.ruby-forum.com/t/counting-number-of-views-on-a-image/141626/2 "2008-06-27T22:46:25Z")

</div>

One obvious, but seemly ugly for some reason, answer is the add a  
count field to the database, and everytime you show the image  
increment that count. I guess it depends on what exactly you count as  
a view.

On Jun 27, 2:38 pm, Nishi A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![nishi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@nishi](https://www.ruby-forum.com/u/nishi)\
**Post date:** [June 27, 2008, 10:53pm UTC](https://www.ruby-forum.com/t/counting-number-of-views-on-a-image/141626/3 "2008-06-27T22:53:24Z")

</div>

Thanks.That sounds convincing enough to me. I don’t know why, for some  
reason it haven’t clicked to me before.
