Increment counter on download

Rails List wrote:

i am offering my site visitors a download of zip file. when someone
downloads it, i want to increment a counter and update db. how do i do
that?

I should think it would be obvious -- just put an increment routine in
the action that generates the zip file. Or if it's a static file, use
your Web server's access logs.

Best,

I am interested in showing the no. of times this file has been
downloaded by updating a text field/area. So using webserver log files
may not help.

I am looking for the possibility of using link_to. When clicked, it
should download the file and update the db in its onclick event.

not sure how to do that/

Rails List wrote:
[...]

I am looking for the possibility of using link_to. When clicked, it
should download the file and update the db in its onclick event.

not sure how to do that/

Apparently you didn't fully read my first message. Go back and do that,
since I explain it there. (Hint: onclick doesn't come into it.)

Best,

In case your penny doesn’t drop:

User clicks link -> Serverside method “download” is triggered -> “download” methods does downloads = downloads + 1, save to db, and then return file to download

Best regards

Peter De Berdt

Thanks Peter. Exactly thats what I have just did using increment.