Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Problem with Dirty when using dynamic properties #130

Open
doro opened this Issue · 2 comments

3 participants

@doro

I am using couchrest model (rails project), and i want to access attributes like this:

person = Person.get(some_id)
person["name"] = "joe"
person.update

and i don't want to define "name" as a property in the Person model. the problem is that the update doesn't work (the document is not updated in couchdb), since the document is not dirty.

the reason, i think, that the document doesn't get dirty when i use the []= method is because it doesn't go via the write_attribute method that uses the Dirty mechanism, but it goes via the []= method in CouchRest::Attributes module

one solution is to do:
person.disable_dirty = true # but that seems dirty.

another solution is to do something like that:
person.send("name=", "joe")

but that's even dirtier, especially if "name" reside in a variable, it will look something like that:
person.send("#{key}=", "joe")

is there a less dirty idea/solution re this issue?

@agilastic

same prob for me here

@metakeule

first of all, you need mass_assign_any_attribute, see http://www.couchrest.info/model/configuring.html#mass_assign

class Person < CouchRest::Model::Base
  mass_assign_any_attribute true
end

then there is an issue with updating, see #114. there is a workaround.

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.