I think I've tracked down the problem, but I'm still not sure whether
it's a problem with Mongoid, MongoDB, Rails or simply my app.
Basically I have a field 'identifier' in each of my models which is
used as key, and the field is populated automatically when creating a
new record. This has always worked without problems, until I updated
my gems as mentioned in the original post.
All my models look similar to this:
class User
include Mongoid::Document
include Mongoid::Timestamps
include GenerateIdentifier
field :identifier
(…)
key :identifier
end
Contrary to my original post, data is still returned as objects now.
For some strange reason though I can access all fields in object style
except for the identifier field. The example in the original post was
simplified and as it turns out not correct. Here's an actual example:
ruby-1.9.2-p136 :001 > user = User.where(:email =>
"
te...@example.com").first
=> #<User _id: 4e445f23058f8e703a7c5e12, _type: nil, identifier:
"b2b3f068a7755a5", first_name: "Matt", last_name: "Test", email:
"
te...@example.com", (…) >
ruby-1.9.2-p136 :002 > user.identifier
=> nil
ruby-1.9.2-p136 :003 > user['identifier']
=> "b2b3f068a7755a5"
ruby-1.9.2-p136 :004 > user.first_name
=> "Matt"
ruby-1.9.2-p136 :005 > user.last_name
=> "Test"
Could it be that 'identifier' is now a reserved word in Mongoid? It
doesn't seem to be a reserved word in Rails.