Save of complex ActiveRecord does not update everything

In my application, a PMR has a list of signatures. A signature has a
list of text lines. I have the appropriate has_many and belongs_to
lines in my model.

I create the whole entity and then do save and the whole entity is
saved. The signature lines are added to the pmr using << and the
text_lines are added to the signature line the same way.

Later, I need to update the PMR. In this case, the fields in the PMR
change. One particular signature changes along with its text lines.
And usually additional signatures are added along with their text lines.
I then do a save and everything is saved (updated) as it should be
except for the changed signature line and its text lines.

Right now, to work around this problem, I am doing a save on the
signature that changes and its text lines but really that isn’t quit
right because I have separate commits.

To change the signature line, I’m modifying it directly like:

pmr.signature_lines[0].attr1 = new_value


pmr.signatures_lines[0].text_line[0] = new_value

Should I be doing this differently? Maybe delete the signature line
from the array and then add it back in with “<<”.

Thank you for your help.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs