This is a fairly common refactoring, Martin Fowler calls it 'move field'. Given 3 models:
class Person < ActiveRecord::Base
has_one :contact_details
has_one :address
end
class ContactDetails < ActiveRecord::Base
end
class Address < ActiveRecord::Base
end
how do I refactor, including migration, the has_one address from Person to ContactDetails? Afterwards the models would look like:
class Person < ActiveRecord::Base
has_one :contact_details
end
class ContactDetails < ActiveRecord::Base
has_one :address
end
class Address < ActiveRecord::Base
end