Skip to content

Instantly share code, notes, and snippets.

@wnstn
Created September 14, 2012 19:44
Show Gist options
  • Save wnstn/3724254 to your computer and use it in GitHub Desktop.
Save wnstn/3724254 to your computer and use it in GitHub Desktop.
patient_migration
def up
patients = Patient.find(:all)
patients.each do |patient|
full_name = patient.name.split
patient.update_attributes(first_name: full_name[0], last_name: full_name[1])
end
end
def down
patients = Patient.find(:all)
patients.each do |patient|
first_name = patient.first_name
last_name = patient.last_name
name = "#{first_name} #{last_name}"
patient.update_attributes(:name: name)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment