I have a category
field of type
Array
in Mongoid.
Ex. category: [\"val1\",\"val2\",\"val3\"]
You can use Criteria all_in
to make it simpler:
Model.all_in(category: ['val1','val2'])
This worked
Model.where(:category.in => ['val1','val2'])
From Mongo Docs
In mongoid, there is '$in' operator. So you can do this :
Model.where(category: { '$in': ['val1', 'val2'] })
Or another variant:
Model.in(category: ['val1','val2'])