Problem with send_data and csv file produced


#1

hi, i did a search and couldn’t find wat’s the problem with my code…
it seems everything is the same and the result is what i expected but i
am not sure where went wrong…

using send_data function to send the csv file to the client, the file
sending is successfully but when i opened the csv file, something is
wrong…

every statement got a “…” inverted commas!!! omg!!! how to get
rid of them!! the data is correct just the why come there is the
inverted commas!! any pro in RoR pls!! help me!!

here is a snippet of the code …

report = String.new
array_csv = Array.new
@csv_record = Model.find_all
CSV::Writer.generate(report, ‘,’) do |csv|
@csv_record.each do |record|
record.attributes.each { |key,value| array_csv.push “#{value}”}
csv << [array_csv.join(’,’)]
array_csv.clear
end
end
report.rewind
send_data(report.read,
:type => ‘text/csv; charset=iso-8859-1;header = present’,
:filename => ‘report.csv’)

this is quite standard as i compared with the others… i didnt include
the dispostion option as it is default to :attachment… is there
anything wrong with it???


#2

oh… haha… a bad mistake… it is caused by the join function at the
array_csv…

thanks for anyone that is solving it…