I have two models Person and Address and a join table Persons::Address containing (person_id, address_id). If my Person object is p, then I do p.addresses_id to get an array of address ids of that person.
Now, I have an after_save callback which uses p.addresses. Let's sat I had p.addresses = [a,b,c]. I ran these two statements after this.
a.addresses = [a,b,d]
a.save
In the after_save callback, if I do self.addresses, I'll get [a,b,d]. I want to make an array A = [a,b,c,d] which should contain the elements of (last array + current array).uniq , what should I do?
Aucun commentaire:
Enregistrer un commentaire