Automatically download file


I'm trying to make a rails-application that checks out and downloads a file in a single click. The user should click on a file, and the application should download the file, update the database and display some results for instance "The file is checked out and downloaded".

I realize this is two responses to a single request, and simply won't work.

I've seen pages like versiontracker that redirects to a new page that pushes a file download from a javascript in the header. (?) Can something like this be done in a more "rails friendly way"?

I'm grateful for any tips!