Downloading a CSV file

I have this app where users can look-up certain information and then save it into a CSV file. My problem is that when a user using IE7 tries to save this file I get an error saying something to the effect that "unable to downlaod because the website could not be contacted," blah blah blah. But, in Chrome and Opera the downloading works fine.

stream_csv do |csv| csv << [ "Sort One", "Sort Two", "Sort Three"] @unusedtickets.each do |unusedticket|    csv << [ unusedticket.sort1, unusedticket.sort2,      unusedticket.sort3,] end end

This is the code that makes the CSV file, I don't know it will help but here it is.

Has anyway come across this kind of thing? Thanks,

-S

Try to set the headers in the start of your action, something like this:

headers['Content-Type'] = "application/vnd.ms-excel" headers['Content-Disposition'] = 'attachment; filename="excel-export.xls"' headers['Cache-Control'] = ''

Cheers.

[ rui ] [ Seiri, Seiton, Seisō, Seiketsu e Shitsuke ]

Wouldn't send_data work for this?

http://api.rubyonrails.org/classes/ActionController/Streaming.html#M000254

Rui Neto wrote:

Rui Neto wrote:

Try to set the headers in the start of your action, something like this:

headers['Content-Type'] = "application/vnd.ms-excel" headers['Content-Disposition'] = 'attachment; filename="excel-export.xls"' headers['Cache-Control'] = ''

Cheers.

[ rui ] [ Seiri, Seiton, Seisō, Seiketsu e Shitsuke ]

On Mon, Nov 3, 2008 at 12:58 PM, Shandy Nantz

What I ended up doing is adding this line:

headers['Cache-Control'] = 'private'

thanks for the responce,

-S