mongoid/mongoid — pull request #2880 by mikerobe (2013-03-09 20:37:02+00:00)
Title: fix IdentityMap not storing relation keys properly

also reported in Issue #2877

This appears to be the right thing to do when storing these keys in the `IdentityMap`. At least it fixes the N+1 problem (which previously was not fixed).

Tested with variants of the following:

``` ruby
Mongoid.identity_map_enabled = true
Mongoid.unit_of_work do
Band.includes(:albums).each do |band|
puts "\n\nShould not see a QUERY log below this line"
p band.albums.first.title # Does not hit the database again. Not true; it does!
end
end
```

and separately with polymorphism, where the classes were structured like this:

``` ruby
class Band
include Mongoid::Document
has_many :albums, as: :commentable
field :name
end

class Album
include Mongoid::Document
belongs_to :commentable, polymorphic: true
field :title
end
```