-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
mongoid (4.0.0.beta1), rails (4.0.1), ruby (2.1.0), mongoDB (2.4.9)
I have a Mongoid Criteria of users and I want to find a user. Given a user that I'm sure doesn't exists in the criteria:
>> users.where(email: user.email).exists?
=> false
>> users.map(&:id).include?(user.id)
=> false
When I search by id I always get the user instead of nil:
>> users.find(user.id)
=> #<User _id: 521a43b37
>> users.where(id: user.id).first
=> #<User _id: 521a43b37
>> users.where(_id: user.id).first
=> #<User _id: 521a43b37
>> users.where(id: user.id).exists?
=> true
Am I doing something wrong?