mongoid/mongoid — Issue #1547: Dirty tracking of embedded doc cleared in after_save for new record
Author: fphilipe
Created: 2012-01-03 22:52:14+00:00
State: open

I observed this today in v2.3.4 and master. Let's assume the following models:

```ruby
class Parent
include Mongoid::Document
embeds_many :children, class_name: 'Parent::Child'
after_save do
puts self.children.map(&:new?)
puts self.children.map(&:changed?)
puts self.children.map(&:changes)
end

class Child
include Mongoid::Document
end
end
```

Now the following happens for a new record:

```ruby
p = Parent.new
p.children.new
p.save
# => false
# => false
# => {}
```

When doing the same on an existing record gives the expected results:

```ruby
p = Parent.create
p.children.new
p.save
# => true
# => true
# => {"_id"=>[nil, BSON::ObjectId('4f0385a3bebaab3487000014')]}
```

This seems to be a bug to me.

Can anyone else reproduce this?