mongoid/mongoid — Issue #1367: Identity map and updating fields in an after_save callback causing stack overflow.
Author: jonhyman
Created: 2011-10-20 22:13:58+00:00
State: open

I have a model that has an after_save callback to update another field if a certain field changes. Today I toyed with turning on the identity map and aren't sure if this is a bug or expected behavior, but it makes that impossible. Here's the simplest case which reproduces it. I'm using Mongoid 2.3.0.

```ruby
class Book
include Mongoid::Document
field :title

after_save :change_title

def change_title
puts("in here")
update_attributes(:title => "Example")
end
end

Book.create
# => prints out "in here" until a SystemStackError is raised
```