:symbol.exists not working on EmbeddedDocument #480

paulwalker opened this Issue Dec 6, 2012 · 1 comment


None yet

2 participants


not sure if this functionality is supposed to map to embedded documents, but:

instance.many_items.find(:array_of_items.exists => 'an_item_in_the_array')

It seems the array returned on the embedded document takes over the normal array #find method (i can't pass a block).

cheald commented Jul 8, 2013

I'm not quite sure how this would work - queries for specific embedded documents on a many proxy can't use Mongo query syntax, since you can't select a specific sub-document out of a document in Mongo (though you can select a document which contains that sub-document!)

In this case, since the association is embedded, you're probably better off just using Ruby:

instance.many_items.detect {|item| item["array_of_items"].include? "an_item_in_the_array" }
@cheald cheald closed this Jul 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment