From 076a59ab458ee065e5acc05bd40946efa875919a Mon Sep 17 00:00:00 2001 From: Jason Denney Date: Mon, 11 Nov 2013 17:27:51 -0500 Subject: [PATCH] Make migration robust to model changes --- db/migrate/20130902201853_add_model_to_bike.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/db/migrate/20130902201853_add_model_to_bike.rb b/db/migrate/20130902201853_add_model_to_bike.rb index f4d1a92..360b8b6 100644 --- a/db/migrate/20130902201853_add_model_to_bike.rb +++ b/db/migrate/20130902201853_add_model_to_bike.rb @@ -3,8 +3,7 @@ class AddModelToBike < ActiveRecord::Migration add_column :bikes, :model, :string change_column :bikes, :bike_model_id, :integer, :null => true Bike.all.each do |bike| - bike.model = BikeModel.find_by_id(bike.bike_model_id).model - bike.save + bike.update_attribute(:model, BikeModel.find_by_id(bike['bike_model_id']).model ) end end end