Created
August 12, 2015 08:26
-
-
Save wuzzzzaah/b450cf14194c155764b4 to your computer and use it in GitHub Desktop.
CSV exporting shit - Rails
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
require 'csv' | |
CSV.open("file_name.csv", "w") do |csv| | |
csv << Model_name.attribute_names | |
#any ar collection | |
ar_collection.each do |record| | |
csv << record.attributes.values | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment