Hello, I would like to reload a page after sending a file to the user through send_data. So far, I have been unable to figure out how to do this and would greatly appreciate some help. In my view, I have: <%= button_to ''Export'', { :action => :export_file }, { :onclick => ''JavaScript:location.reload(true);'' } %> In my controller: def export_file # generate file here send_data(file_data, :filename => ''file.txt'') end This doesn''t work properly at all. In Firefox, the file is sent and the page is reloaded but is not rendered (I verified this by looking at the page source before and after). In Internet Explorer, the page does get reloaded but the file is not sent. Thank you, Jason --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Tue, 2008-06-03 at 17:28 -0700, jasoo24 wrote:> Hello, > > I would like to reload a page after sending a file to the user through > send_data. So far, I have been unable to figure out how to do this and > would greatly appreciate some help. > > In my view, I have: > > <%= button_to ''Export'', { :action => :export_file }, { :onclick => > ''JavaScript:location.reload(true);'' } %> > > In my controller: > > def export_file > # generate file here > send_data(file_data, :filename => ''file.txt'') > end > > > This doesn''t work properly at all. In Firefox, the file is sent and > the page is reloaded but is not rendered (I verified this by looking > at the page source before and after). In Internet Explorer, the page > does get reloaded but the file is not sent.---- http://wiki.rubyonrails.com/rails/pages/HowtosFiles should be able to find what you''re looking for here. Craig --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for that resource, Craig. It will certainly come in handy, however, I was unable to find the answer to my question there. I am dynamically generating a file and then sending it back to the client with send_data. At the same time, I would like to reload the current page. I would appreciate any help with this. I do have a simple workaround in place using Javascript (in case, someone else looking for help wanders here...): <%= button_to ''Export'', { :action => :export_file }, :onclick => "this.disable(); $(''count'').innerHTML = ''0'';" %> I would much prefer to reload the page though. Thanks for any help. Jason On Jun 3, 6:06 pm, Craig White <craigwh...-BQ75lA0ptkhBDgjK7y7TUQ@public.gmane.org> wrote:> On Tue, 2008-06-03 at 17:28 -0700, jasoo24 wrote: > > Hello, > > > I would like to reload a page after sending a file to the user through > > send_data. So far, I have been unable to figure out how to do this and > > would greatly appreciate some help. > > > In my view, I have: > > > <%= button_to ''Export'', { :action => :export_file }, { :onclick => > > ''JavaScript:location.reload(true);'' } %> > > > In my controller: > > > def export_file > > # generate file here > > send_data(file_data, :filename => ''file.txt'') > > end > > > This doesn''t work properly at all. In Firefox, the file is sent and > > the page is reloaded but is not rendered (I verified this by looking > > at the page source before and after). In Internet Explorer, the page > > does get reloaded but the file is not sent. > > ----http://wiki.rubyonrails.com/rails/pages/HowtosFiles > > should be able to find what you''re looking for here. > > Craig--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---