0

我想更改此查询:

messages = messages.where("name like :search or category like :search", search: "%#{params[:sSearch]}%")

查询mongoid

谢谢!

4

1 回答 1

1

对于 Mongoid 2.x:

messages = messages.any_of({ name:     /#{params[:sSearch]}/ }, 
                           { category: /#{params[:sSearch]}/ })
于 2012-11-29T16:20:31.467 回答