i use rails and mongodb (mongoid gem). i need to create a select form with specific elements which are embedded in a document. the document looks like this:
App –> Order –> Package
I want to get just the app-documents where package has a specific value. any advice how to achieve this? I tried the following way, but doesn’t work:
@apps = current_user.apps.order.all(conditions: { order.package: 2 } )
Check out this question: Mongoid / Mongodb and querying embedded documents
In your case:
A way to test in the mongo shell: