ZhangHanDong / mongoid_counter_cache

Mongoid Counter Cache
11 stars 2 forks source link

Mongoid 2.2.0: Can't modify frozen hash on destroy #1

Open nickw opened 13 years ago

nickw commented 13 years ago

Using Mongoid 2.2.0, Rails 3.1.0 and mongoid_counter_cache 0.02 - I'm getting the following error when calling destroy on a record:

can't modify frozen hash

mongoid (2.2.0) lib/mongoid/attributes.rb:104:in `[]='
mongoid (2.2.0) lib/mongoid/attributes.rb:104:in `block (2 levels) in write_attribute'
mongoid (2.2.0) lib/mongoid/attributes.rb:100:in `tap'
mongoid (2.2.0) lib/mongoid/attributes.rb:100:in `block in write_attribute'
mongoid (2.2.0) lib/mongoid/attributes.rb:170:in `assigning'
mongoid (2.2.0) lib/mongoid/attributes.rb:98:in `write_attribute'
mongoid (2.2.0) lib/mongoid/fields.rb:314:in `block (2 levels) in create_accessors'
mongoid (2.2.0) lib/mongoid/relations/bindings/referenced/in.rb:25:in `block in bind'
mongoid (2.2.0) lib/mongoid/relations/binding.rb:21:in `binding'
mongoid (2.2.0) lib/mongoid/relations/bindings/referenced/in.rb:23:in `bind'
mongoid (2.2.0) lib/mongoid/relations/proxy.rb:19:in `bind_one'
mongoid (2.2.0) lib/mongoid/relations/referenced/in.rb:24:in `block in initialize'
mongoid (2.2.0) lib/mongoid/relations/proxy.rb:34:in `init'
mongoid (2.2.0) lib/mongoid/relations/referenced/in.rb:22:in `initialize'
mongoid (2.2.0) lib/mongoid/relations/accessors.rb:44:in `new'
mongoid (2.2.0) lib/mongoid/relations/accessors.rb:44:in `create_relation'
mongoid (2.2.0) lib/mongoid/relations/accessors.rb:26:in `build'
mongoid (2.2.0) lib/mongoid/relations/accessors.rb:100:in `block (3 levels) in getter'
mongoid (2.2.0) lib/mongoid/relations/builders.rb:47:in `building'
mongoid (2.2.0) lib/mongoid/relations/accessors.rb:99:in `block (2 levels) in getter'
mongoid_counter_cache (0.0.2) lib/mongoid_counter_cache.rb:41:in `block in counter_cache'
activesupport (3.1.0) lib/active_support/callbacks.rb:392:in `_run_destroy_callbacks'
activesupport (3.1.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
mongoid (2.2.0) lib/mongoid/persistence.rb:31:in `destroy'
app/controllers/resources_controller.rb:47:in `destroy'
alecnmk commented 13 years ago

I'm getting the same w/o counter cache gem with mongoid 2.2.0 and Rails 3.0.9. So that's probably mondoid issue.

alecnmk commented 13 years ago

Found mongoid issue related to that one: https://github.com/mongoid/mongoid/issues/1176