ruby on rails - query in mongoid search in multiple condition -
my model this
def self.search(search) if search self.full_text_search(search) else scoped end end
but need add also
self.or({start_date: /#{regexp.escape(search)}/i},{end_date: /#{regexp.escape(search)}/i})
in above search . how join 2 condition in above search. 2 query works fine independently. need make them join together. working example helpful
you can join 2 mongoid criterias using merge method:
q1 = self.scope q2 = self.or(...) result = q1.merge(q2)
here relevant documentation:
http://rdoc.info/github/mongoid/mongoid/master/mongoid/criteria#merge-instance_method
Comments
Post a Comment