Scoping queries

We can scope queries in Mongoid using class methods:

Class Book
...
def self.premium
where(price: {'$gt': 20'})
end
End

Then use this:

Book.premium

It will query for books with price greater than 20.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.27.58