Last active
September 19, 2018 18:57
-
-
Save chelseatroy/0f3d99c1ea22eb5e87b8c992c07cbcdc to your computer and use it in GitHub Desktop.
Example: Process-Oriented Data Import
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 characters
class Import | |
def import_workouts(rows) | |
CSV.foreach(@import_file_path, {headers: true}) do |row| | |
attributes = row.to_hash | |
workout = Workout.new(attributes) | |
unless workout.save | |
workout.save(validate: false) | |
workout.update_column(:status, :needs_revision) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment