Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Last active September 19, 2018 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/0f3d99c1ea22eb5e87b8c992c07cbcdc to your computer and use it in GitHub Desktop.
Save chelseatroy/0f3d99c1ea22eb5e87b8c992c07cbcdc to your computer and use it in GitHub Desktop.
Example: Process-Oriented Data Import
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