Created
September 14, 2012 19:44
-
-
Save wnstn/3724254 to your computer and use it in GitHub Desktop.
patient_migration
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
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