Skip to content

Instantly share code, notes, and snippets.

View d3vkit's full-sized avatar

Christina d3vkit

View GitHub Profile
@d3vkit
d3vkit / csv_export.rb
Last active March 25, 2019 17:56 — forked from foxumon/csv_export.rb
Export table to CSV with all attributes in rails console
folder = Rails.root.join('public', 'csv', 'data')
tables = ActiveRecord::Base.connection.tables
tables.each do |table|
klass = table.classify.safe_constantize
next unless klass && klass.respond_to?(:find_each)
data = klass.scoped
next unless data.any?