Reputation: 15089
Is there a simple way to do this.
Let's say i have 4 Person
objects that somehow refer to the same person.
All of them have some attributes correctly filled, e.g. @person1
has age
and gender
, @person2
have last_name
, @person3
have observation
and @person4
have mother_name
.
In addition to these simple attributes, there is some relashionships between another ActiveRecord
models.
For example @person1
might have 2 notes, @person2
might have 1 note and 2 adresses, and so on.
The thing i am looking for is a way to make all these four objects to be merged together preserving all the filled attributes and all the relashionships.
Example, in the end i would have something like this: a Person
object with age, gender, last_name, observation, mother_name, 3 notes, 2 adresses, etc
.
Upvotes: 0
Views: 727
Reputation: 7211
Did you have a look at the ar_merge gem yet? https://github.com/grosser/ar_merge It hasn't been updated for a couple of months but looking at it, I guess it should still be compatible.
Upvotes: 1