|
@ -11,8 +11,7 @@ class AlterBikeWheelToId < ActiveRecord::Migration |
|
|
else |
|
|
else |
|
|
wheel_size_id = wheel_size.id |
|
|
wheel_size_id = wheel_size.id |
|
|
end |
|
|
end |
|
|
bike.bike_wheel_size_id = wheel_size_id |
|
|
bike.update_attribute(:bike_wheel_size_id, wheel_size_id) |
|
|
bike.save |
|
|
|
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
remove_column :bikes, :wheel_size |
|
|
remove_column :bikes, :wheel_size |
|
@ -24,8 +23,7 @@ class AlterBikeWheelToId < ActiveRecord::Migration |
|
|
|
|
|
|
|
|
Bike.find_each do |bike| |
|
|
Bike.find_each do |bike| |
|
|
wheel_size = BikeWheelSize.find_by_id(bike['bike_wheel_size_id']) |
|
|
wheel_size = BikeWheelSize.find_by_id(bike['bike_wheel_size_id']) |
|
|
bike.wheel_size = wheel_size.rdin.to_i |
|
|
bike.update_attribute(:wheel_size, wheel_size["rdin"].to_i) |
|
|
bike.save |
|
|
|
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
remove_column :bikes, :bike_wheel_size_id |
|
|
remove_column :bikes, :bike_wheel_size_id |
|
|