Making @headers['Refresh'] and send_file work together?


I’ve got a Rails 1.1 app where people can click a link to download a
custom-generated file. The link to “Download Zip” goes to /
controller/get_zip. That action looks like this:

def get_zip
@cart = find_cart
ids =
@cart.songs.each do |song|

 args = ids.join(" ")
 zipfile = `#{RAILS_ROOT}/perl/ #{args}`
   size = File.stat(zipfile).size
   filename = ""
   send_file(zipfile, :filename => filename, :type =>

“application/zip”, :str
eaming => false)
flash[:warning] = “Zip file no longer exists - did you already
download it
redirect_to(:controller => “/online”)

I’d like to have the user get sent to a different page a few seconds
after the download starts. In a previous incarnation of this app,
I’d set the HTTP “Refresh” header before sending the binary data. In
fact, on a standard controller action that just renders RHTML, I can do:

  @headers["Refresh"] = '5, url='

And it works as expected - 5 seconds after the action is rendered,
I’m redirected.

However, if I set that header before doing the send_file, nothing
happens. The file downloads properly - no problems there - but no
redirect. Looking through the source, it doesn’t seem like the
@headers are getting overwritten, just updated. But it’s certainly
not refreshing.

Any thoughts on how to make this work (or another way to accomplish
what I’m trying to do?