Take the 2-minute tour ×

In former version of Mongoid I would write:

Clothes.where("$or" => [{"$and" => [{_type: "Shoes"}, {is_secondhand: false}]}, 
                        {"$and"=> [{_type: "Shirts"}, {is_secondhand: true}]}])

How should I write that in Mongoid 3.0.13?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

You probably don't need those ands.

Try this:

Clothes.or({_type: "Shoes", is_secondhand: false},
           {_type: "Shirts", is_secondhand: true})

A lot has changed in Mongoid 3 and most of the querying selectors were moved to Origin. Have a look at the Origin documentation.

share|improve this answer
It works,thanks a lot.:) –  alikewmk Nov 21 '12 at 2:09
add comment

Your Answer


