Nested changes #73

andymorris opened this Issue Oct 31, 2012 · 1 comment


None yet
2 participants

andymorris commented Oct 31, 2012

Changes in properties whose type also mixes in CouchPotato::Persistence, or array properties, are not reflected in the root object's #changes method. This complicates code like the following:

plant = db.load_document(id)
plant.branch.leafs = 3 plant # does not save because plant.changes is empty

plant.array_property << new_value plant # again plant.changes is empty

#is_dirty exists to help with this, but it would also be nice to have a way to get deep/nested changes for auditing and other purposes. I plan on implementing this and would like to see it pulled into the project.

One question though: should a new method be added to get these changes (top level + nested) for purposes of backward and ActiveModel compatibility? Or should the existing #changes method be modified to also include nested changes? Or maybe it can be opt-in by including a DeepChanges module that overwrites #changes and related methods?


langalex commented Oct 31, 2012

yes, I would prefer a separate module. couch potato actually had this feature a long time ago but I removed it over performance issues.

langalex closed this May 18, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment