# Send a file then redirect to another page

**URL:** <https://www.ruby-forum.com/t/send-a-file-then-redirect-to-another-page/153410>\
**Category:** Rails\
**Created:** [November 16, 2008, 7:43pm UTC](https://www.ruby-forum.com/t/send-a-file-then-redirect-to-another-page/153410 "2008-11-16T19:43:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [November 16, 2008, 7:43pm UTC](https://www.ruby-forum.com/t/send-a-file-then-redirect-to-another-page/153410/1 "2008-11-16T19:43:12Z")

</div>

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  
 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

---

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [November 16, 2008, 8:23pm UTC](https://www.ruby-forum.com/t/send-a-file-then-redirect-to-another-page/153410/2 "2008-11-16T20:23:34Z")

</div>

Max W. wrote:

> 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
