Created
December 2, 2022 14:05
-
-
Save mattantonelli/1115e7f91dcde77b7f52563cc7a21ace to your computer and use it in GitHub Desktop.
Simple dump of specified columns for a Rails model
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
headers = %w(column1 column2 column3) | |
CSV.open('tmp/output.csv', 'wb') { |csv| csv << headers; MyModel.each { |app| csv << app.attributes.values_at(*headers) } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment