I have a Mongoid document with embedded documents in it. I want to search the top-level documents for all of them where there is an embedded document that has multiple criteria.
TopDoc.where('inside.first_name' => 'Bob', 'inside.last_name' => 'Jones')
But it seems to me this would match on a TopDoc with Bob Wever and Paul Jones, which is wrong.
You need to use $elemMatch. With Mongoid, the following line should do the trick
which is equivalent to :