0

Guys I hav below code snippet and I need remove an element from animals array, but I get UpdateConflictError

zoo.animals # => Wolf,Tiger,Lion
zoo.animals.delete("Wolf") # => Tiger, Lion
zoo.update(:animals => zoo.animals)
# => DataMapper::UpdateConflictError: Zoo#update cannot be called on a dirty resource
zoo.update #=> also give me the same error

I have to query the zoo.animals and then remove Wolf but seems not successful. What you recommend? thanks.

P.S: here datamapper has explained about dirty resources but I have no other alternative.

tokhi
  • 21,044
  • 23
  • 95
  • 105
  • Just first select the right object, and call the correct method, i.e., `zoo.animals.get("Wolf").destroy` (`get` uses the primary key, so another option would be the `.first(:property => "Wolf")`). – morbusg Mar 13 '13 at 15:46

1 Answers1

0

This has resolved the error:

zoo.animals # => Wolf,Tiger,Lion
zoo.animals.delete("Wolf") # => Tiger, Lion
zoo.save
tokhi
  • 21,044
  • 23
  • 95
  • 105