Deleting Data After Viewing On Page

I’m creating a site that allows users to upload a picture. The picture
they uploaded will be shown randomly for a period of time then another
one will come on. When they upload it, they pay a certain price,
depending on how many times they want it to be viewed. I want it to be
made that it’s one dollar per amount of times it can be viewed. Thus,
if they pay $5, their picture will be shown 5 random times, but no more.
My question is how to do this. I want to figure out how to make the data
in the table delete itself after it is viewed the amount of times paid
for. I’m not sure how to count the number of views nor make the data
delete itself. Any help would be greatly appreciated!

Tom D. wrote:

I’m creating a site that allows users to upload a picture. The picture
they uploaded will be shown randomly for a period of time then another
one will come on. When they upload it, they pay a certain price,
depending on how many times they want it to be viewed. I want it to be
made that it’s one dollar per amount of times it can be viewed. Thus,
if they pay $5, their picture will be shown 5 random times, but no more.
My question is how to do this. I want to figure out how to make the data
in the table delete itself after it is viewed the amount of times paid
for. I’m not sure how to count the number of views nor make the data
delete itself. Any help would be greatly appreciated!

you can do something like this
add column “picture_view” in database put value of it is equal to amount
that user pay if user pay $5 then make picture_view=5
then after each time picture shown reduce picture_views count by 1
if picture_view is 0(zero) then give such a condition that it will not
be displayed

My understand is before displaying a picture, you should check the
user’s
account, if there’s no enough money then redirect to some page to show a
notice.
Since users and pictures are n:n relationships, if you want to add a
column to record times each people view the picture, it would be
amount_of_users * amount_of_pics records needed. And I don’t think you
need
to delete the picture.

before_filter :check_account, :only => :display_pic

def display_pic

random get pic

end

private
def check_account
redirect_to :some_where if current_user.balance < price_per_pic
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs