I'm trying to export my report in a CSV format document. For that i used fasterCSV but,i faced
Please switch to Ruby 1.9's standard CSV library.
It's FasterCSV plus support for Ruby 1.9's m17n encoding engine.
error. Can any one help me to solve this error? my code as follows
csv_string = FasterCSV.generate do |csv|
csv << ["Client_name", "Created_at", "User type"]
@client_reports.each do |client_reports|
csv << [client_reports.email, client_reports.created_at,client_reports.role_name]
end
end
send_data csv_string,
:type => 'text/csv; charset=iso-8859-1; header=present',
:disposition => "attachment; filename=product_stock.csv"
So please help me to resolve this in Ruby 1.9.3. It work's fine in Ruby 1.8.7.
Or if you can suggest me any other resource please help me out with that example?
As of Ruby 1.9.2 FasterCSV is already included as standard library's CSV. Just change references in your application from FasterCSV to CSV and it should work. Check out the docs and this new Railscast.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With