Created
October 8, 2011 02:20
-
-
Save geronimod/1271758 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
csv_data = FasterCSV.generate do |csv| | |
# por ahora todas pero habra que dejar afuera la imagen y los templates html | |
# headers | |
csv << Product.columns.map(&:name) | |
Product.all.each do |record| | |
csv << Product.columns.map { |c| record.send(c.name) } | |
end | |
end | |
filename = "data-#{Time.now.to_date.to_s}.csv" | |
send_data(csv_string, :type => 'text/csv; charset=utf-8; header=present', :filename => filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment