Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

autosave options in Ruby on Rails

Is there a way to turn OFF autosave in Rails? I don't want modifications to an association to automatically save to the database UNTIL I call save on the parent object.

some_parent.some_children << child #should not save, just adds to the association!

some_parent.save #now parent and children are saved!

It this possible or am I barking up the wrong tree?

like image 854
fregas Avatar asked Oct 26 '25 15:10

fregas


1 Answers

I think this may be close enough to provide some help.

some_parent.some_children.build({:child_attr1 => 'child_val1'})
some_parent.save # should save the new child as well
like image 162
vise Avatar answered Oct 29 '25 06:10

vise



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!