# Authenticity\_token shows up in the url when page reloads

**URL:** <https://www.ruby-forum.com/t/authenticity-token-shows-up-in-the-url-when-page-reloads/189750>\
**Category:** Rails\
**Created:** [June 7, 2010, 6:37am UTC](https://www.ruby-forum.com/t/authenticity-token-shows-up-in-the-url-when-page-reloads/189750 "2010-06-07T06:37:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![albino\_squirrel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9a28c/32.png) [@albino\_squirrel](https://www.ruby-forum.com/u/albino_squirrel)\
**Post date:** [June 7, 2010, 6:37am UTC](https://www.ruby-forum.com/t/authenticity-token-shows-up-in-the-url-when-page-reloads/189750/1 "2010-06-07T06:37:02Z")

</div>

I’m pretty new to Ruby On Rails (and somewhat self-taught), so bear with  
me if I’m asking something stupid. So whenever I push my download button  
(which just uses send\_file, if that’s any help) it reloads the page,  
without downloading, and it puts the authenticity\_token in the url. This  
all the button is:  
\<% form\_remote\_tag :url =\> { :action =\> ‘download’} do %\>  
\<%= submit\_tag “Download” %\>  
\<% end %\>

Basically, it’s just not working at all, and I would appreciate any sort  
of help with the issue. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![albino\_squirrel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9a28c/32.png) [@albino\_squirrel](https://www.ruby-forum.com/u/albino_squirrel)\
**Post date:** [June 7, 2010, 10:10am UTC](https://www.ruby-forum.com/t/authenticity-token-shows-up-in-the-url-when-page-reloads/189750/2 "2010-06-07T10:10:30Z")

</div>

On 07 Jun 2010, at 06:37, Stephen Kilbourn wrote:

> \<% end %\>
> 
> Basically, it’s just not working at all, and I would appreciate any  
> sort  
> of help with the issue. Thanks in advance.

Downloading a file is a “full page refresh” (although the page won’t  
actually refresh). You shouldn’t use an AJAX function (whether that’s  
a link or a form) to send a file to the client. Just serve it up with  
the right content type as a normal request and you’ll be fine.

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![albino\_squirrel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9a28c/32.png) [@albino\_squirrel](https://www.ruby-forum.com/u/albino_squirrel)\
**Post date:** [June 9, 2010, 2:52am UTC](https://www.ruby-forum.com/t/authenticity-token-shows-up-in-the-url-when-page-reloads/189750/3 "2010-06-09T02:52:31Z")

</div>

Peter De Berdt wrote:

> Downloading a file is a “full page refresh” (although the page won’t  
> actually refresh). You shouldn’t use an AJAX function (whether that’s  
> a link or a form) to send a file to the client. Just serve it up with  
> the right content type as a normal request and you’ll be fine.

I get what you’re saying and I’ve tried a few different methods. But  
alas, I am a beginner and have not gotten anything to work. Would you  
maybe happen to have any specific ideas as to how I could remedy my  
solution. Thanks again for your help.

---

<div class="post-metadata">

**Author:** ![albino\_squirrel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9a28c/32.png) [@albino\_squirrel](https://www.ruby-forum.com/u/albino_squirrel)\
**Post date:** [June 9, 2010, 4:21am UTC](https://www.ruby-forum.com/t/authenticity-token-shows-up-in-the-url-when-page-reloads/189750/4 "2010-06-09T04:21:21Z")

</div>

Nevermind, I got it… Still couldn’t have gotten it without your help.  
Thanks.
