mongoid/mongoid — pull request #3386 by glebtv (2013-11-08 16:51:49+00:00)
Title: Enforce polymorphic ID to be ObjectID

Currently, in polymorphic relation when setting id as string it is stored as string.
This doesn't break loading of relation (comment.commentable), but it breaks inverse relation (commenable.comments)

Primary reason for this is rails_admin is setting polymorphic relations exactly this way, as strings, which breaks a lot of things in my apps after saving a model in rails_admin.

I had to use this workaround:
```ruby
before_validation do
if imageable_id.class.name == 'String'
self.imageable_id = BSON::ObjectId.from_string(imageable_id)
end
true
end
```

This might break things for people who might have string or integer IDs or something like that with polymorphic models.