Forum: Ruby on Rails send a file then redirect to another page

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
73c04e9ef9ca435c5b19a2e765ae6d20?d=identicon&s=25 Max Williams (max-williams)
on 2008-11-16 19:43
I'm editing a controller action that previously used "send_file" to send
a file and then just returned, like

send_file(some_params) and return

Now, though, the downloading has been moved into a different controller
action, and i need to get back to the 'show' page after the user starts
downloading the file.  After doing the send_file, i tried to render the
show action, but this makes the controller think that the show page url
is the file i'm trying to send: i get an error message like "The file
<show page url here> could not be located...".

Can anyone tell me if/how i can send the file and then
redirect_to/render another view page?

thanks
max
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-11-16 20:23
(Received via mailing list)
Max Williams wrote:
> <show page url here> could not be located...".
You can't. The browser has made an http request and you get to provide
one response, either you render a template/send a file (those two are
basically the same thing: a 200 response containing some data) or you
redirect (a 30x response telling the browser where to go). You can't
do both.

Fred
This topic is locked and can not be replied to.