Forum: Ruby on Rails save of complex ActiveRecord does not update everything

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
3f38541776a2513a20ea2f1c2d522cb3?d=identicon&s=25 Perry Smith (pedz)
on 2007-06-08 19:46
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 topic is locked and can not be replied to.