# Save of complex ActiveRecord does not update everything

**URL:** <https://www.ruby-forum.com/t/save-of-complex-activerecord-does-not-update-everything/106341>\
**Category:** Rails\
**Created:** [June 8, 2007, 7:46pm UTC](https://www.ruby-forum.com/t/save-of-complex-activerecord-does-not-update-everything/106341 "2007-06-08T19:46:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [June 8, 2007, 7:46pm UTC](https://www.ruby-forum.com/t/save-of-complex-activerecord-does-not-update-everything/106341/1 "2007-06-08T19:46:22Z")

</div>

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

or

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.
