|
Subject: Re: Export to Excel Help Newsgroups: gmane.comp.lang.ruby.rails Date: 2005-07-26 07:37:14 GMT (3 years, 49 weeks, 1 day, 20 hours and 32 minutes ago)
I think that problem is with your setup, that is why you get the same
error. Now send_data fails faster, as you are only sending a string
instead of file content: i.e: RAILS_ROOT + "public/export.csv"
BTW: this will generate CSV data directly to a string buffer instead file:
require 'stringio'
require 'csv'
def export
StringIO.open do |io|
CSV::Writer.generate(io) do |writer|
writer << ['r1c1', 'r1c2']
writer << ['r2c1', 'r2c2']
writer << [nil, nil]
end
send_data io.string, :filename => "my_data.csv"
end
end
Zsombor
On 7/25/05, Gregg Pollack <patched@...> wrote:
> Zsombor,
>
> I have tried both send_data and send_file. They both render the
> same error I listed. The only difference is that send_file takes about 10
> seconds for the server to respond, where as send_data is instantaneous.
>
> How would I use rail's CSV tools to create a buffer which I could
> then send? This is not clear.
>
> Thanks for the response though,
>
--
http://deezsombor.blogspot.com
|
|
|