# Picture Slideshow using a database

**URL:** <https://www.ruby-forum.com/t/picture-slideshow-using-a-database/174469>\
**Category:** Rails\
**Created:** [August 27, 2009, 5:32am UTC](https://www.ruby-forum.com/t/picture-slideshow-using-a-database/174469 "2009-08-27T05:32:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tdellaringa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7bcc69/32.png) [@tdellaringa](https://www.ruby-forum.com/u/tdellaringa)\
**Post date:** [August 27, 2009, 5:32am UTC](https://www.ruby-forum.com/t/picture-slideshow-using-a-database/174469/1 "2009-08-27T05:32:21Z")

</div>

On my site, I am having a sort of slideshow in which people can purchase  
the ability to put a picture on. It’s sort of a one shot deal thing, in  
which someone can go on and navigate to a page that allows them to pick  
a picture, give a description, and then choose a payment option. This  
payment option is something like if they want their picture to be shown  
for 10 seconds, it will cost $1, 20 seconds would be $2, and maybe a  
minute for $5 or some sort of deal. On top of that, I also would like  
to have a part in which they can choose the number of times they want it  
shown for that time, such as two 10 second deals, although it’ll still  
be the same picture, and that will then double the cost.  
However, my question is how to do this. I need to be able to remove  
their picture from a database after it’s been viewed, unless they’ve  
purchased a quantity of two or more, in which case I need the fact that  
it’s been viewed once already reflected in the database. I have no idea  
how to count how many times it’s been used in the slideshow, nor how to  
set a time limit in the slideshow. Any help would be appreciated and if  
you have questions don’t be afraid to ask.

---

<div class="post-metadata">

**Author:** ![tdellaringa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7bcc69/32.png) [@tdellaringa](https://www.ruby-forum.com/u/tdellaringa)\
**Post date:** [August 27, 2009, 6:39pm UTC](https://www.ruby-forum.com/t/picture-slideshow-using-a-database/174469/2 "2009-08-27T18:39:07Z")

</div>

On Aug 26, 11:32 pm, Tom D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ## However, my question is how to do this. I need to be able to remove their picture from a database after it’s been viewed, unless they’ve purchased a quantity of two or more, in which case I need the fact that it’s been viewed once already reflected in the database. I have no idea how to count how many times it’s been used in the slideshow, nor how to set a time limit in the slideshow. Any help would be appreciated and if you have questions don’t be afraid to ask.

Model hm: image\_views

store duration on image\_views, create an image\_view for every view  
(the quantity), deleting the record every time the image is viewed.

In your controller you can use send\_file to serve the image. Maybe you  
could do a has\_many :through to find the image through the image view,  
and delete the image view here when you serve up the file with  
send\_file.
