Forum: Ruby on Rails Problem with send_data and csv file produced

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bao L. (Guest)
on 2006-05-22 12:44
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?????
Bao L. (Guest)
on 2006-05-22 12:55
oh... haha... a bad mistake... it is caused by the join function at the
array_csv.....

thanks for anyone that is solving it...
This topic is locked and can not be replied to.