Skip to content

Instantly share code, notes, and snippets.

View toby-1-kenobi's full-sized avatar
💭
Getting Rev79 ready for international

Toby Anderson toby-1-kenobi

💭
Getting Rev79 ready for international
View GitHub Profile
@foxumon
foxumon / csv_export.rb
Created April 29, 2016 20:19
Export table to CSV with all attributes in rails console
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 }