Reload page after send_data

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

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.

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