Picture Slideshow using a database

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.

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.