The Rails way to download a file...

i'm not sure you can - the download is the last thing you need to do in order to make things work. so you show the status page, which then redirects the browser to the download after it has loaded (via a javascript redirect probably), so the user is left with the status page on the screen and a download box.

something like
action:
def download
    if params = correct
       @download = true
    else
       @download = false
       errors.add etc
    end
end

and then in download.rhtml:
<body <%if @download%>
    onload="window.location='<%=url_for(:controller=>"download",:action=>"really_do_the_download")%>'"
<%end%>>
<%if @download%>
Downloading...
<%else%>
There were errors!
<%end%>

Edwin Moss wrote: