Simple file download doesn't work - please help!

I need to get a simple file download to work. I want users to be able to click 'I agree' after scrolling through a license agreement and the click initiates a download of some software which is in a zip file.

I tried using send_file and had some problems I previously posted about. So I am trying to not use send_file. (If anyone can help me with my previous send_file post, that would be great, but please don't suggest send_file otherwise, thanks).

So, I have:      <input type=button value="I AGREE" onclick="do_download();"> in one of my rhtml files, where do_download is a javascript fcn: function do_download() {   location.href = '/products/download_sample.zip' }

The browser is supposed to see that this is a zip file and put up a pop up window that queries whether to save or open. Standard.

In a vanilla html page, what I want to happen is what happens. When I'm in my RoR site, the browser opens the zip file in a new window, and displays garbage.

This is not a problem that the browser is configured to open zip files. Outside of RoR, it doesn't. But something in Rails (the routes? What?) is making the browser try to open zip files. What is it?

How can I get the behavior I want?

thanks so much!

In regards to your last post about send_file, you need to get rid of the redirect. You don't want to redirect, you want to send this file. The syntax should be:

send_file('/usr/var/somefile.zip')

Note that the file path will need to be the path to the file on the filesystem, not what you would retrieve via a HTTP request. All the other default options are set to make the browser request to save the file so probably best to leave them be until you get it working.