Skip to content

Disable Dirty Tracking #121

Open
roryfranklin opened this Issue Oct 17, 2011 · 2 comments

2 participants

@roryfranklin

Hi,

Is there a way to disable the dirty tracking functionality? This has been causing a lot of problems for us where documents with nested data structures aren't being saved because it doesn't think the attribute has changed, and rather than use the couchrest_attribute_will_change! method every time we need to save, we'd like to blanket turn off the functionality as we don't use it anyway.

Is that possible?

@raldred
raldred commented Nov 2, 2011

Yeh, there's some real issues with the dirty tracking it would seem. As soon as you try to store data structures it completely falls down. Experiencing the same pain here.

@raldred
raldred commented Nov 4, 2011

looking at the source[1] this might work

Model < CouchRest::Model::Base
    disable_dirty true
end

the comparisons in dirty are buggy, casted arrays and hashes do not correctly compare.
if you modify a deep hash/array it doesn't recognise the changes, ive been trying to figure out why.

there is a method to force couchrest into thinking a field has changed. just call it on your model instance like so...

model_instance.couchrest_attribute_will_change!('<attribute_name>')

I dont know how supported this is and may change in future versions.

[1] https://github.com/couchrest/couchrest_model/blob/master/lib/couchrest/model/dirty.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.