here my code in model is
def self.search(search)
if search
where(name: /#{Regexp.escape(search)}/i)
else
scoped
end
end
Now i want to add another field also to search
like
where(price: /#{Regexp.escape(search)}/i)
So my query should search two field
like
where(name: /#{Regexp.escape(search)}/i) (or) where(price: /#{Regexp.escape(search)}/i)
How to add this two field in mongodb like or . Working example is accepted.
Since i have less knowledge about mongodb.
If you are using Mongoid 3, you can write your query like this:
If you are using something other than Mongoid 3 (like MongoMapper or Mongoid 2), please give the name and version number.
Source: Selection syntax docs for Mongoid 3 are here.