Created
April 29, 2016 20:19
-
-
Save foxumon/fdb30349545944eee58c7858e6bab23c to your computer and use it in GitHub Desktop.
Revisions
-
foxumon created this gist
Apr 29, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ require 'csv' file = "#{Rails.root}/public/data.csv" table = User.all;0 # ";0" stops output. Change "User" to any model. CSV.open( file, 'w' ) do |writer| writer << table.first.attributes.map { |a,v| a } table.each do |s| writer << s.attributes.map { |a,v| v } end end