Mongoid failing to find document by nested ID
I have a collection with documents that look something like this:
{
_id: ObjectId("521d11014903728f8d000006"),
association_chain: [
{
name: "Foobar",
id: ObjectId("521d11014903728f8d000005")
}
],
// etc...
}
I can search by the name attribute with this query:
@results = Model.where 'association_chain.name' => 'Foobar'
This returns the results as expected. However, when I try to search using
the id attribute:
@results = Model.where 'association_chain.id' => '521d11014903728f8d000005'
There are no results. What am I doing wrong?
No comments:
Post a Comment