Forum: Ruby on Rails Making @headers['Refresh'] and send_file work together?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
H. Wade M. (Guest)
on 2006-04-13 06:10
(Received via mailing list)
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?
This topic is locked and can not be replied to.