mongoid/mongoid — Issue #1716: Embedded document created_at is nil
Author: stephan778
Created: 2012-02-14 15:29:16+00:00
State: open

I have `Group` and `Event` models:

```ruby
class Group
include Mongoid::Document
include Mongoid::Timestamps::Created

field :name

embeds_many :history, class_name: 'History::Group::Event'
end

module History
module Group
class Event
include Mongoid::Document
include Mongoid::Timestamps::Created

embedded_in :group, class_name: 'Group', inverse_of: :history
belongs_to :user
end
end
end
```

Running

```ruby
g = Group.new(name: 'test')
g.history << History::Group::MemberAdded.new(user: User.first)
g.save!
```
results in `g.history.first.created_at` being `nil`. Note that the object `g.history.first` itself is saved correctly (user id is the one I gave, etc).

However when I do

```ruby
g = Group.create(name:'test')
g.history << History::Group::MemberAdded.new(user: User.first)
g.save!
```
I get a proper value for `g.history.first.created_at`