Guest User

Untitled

a guest
Nov 16th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #
  2. # In your model, you'll want these scopes, so this query logic can be reused elsewhere
  3. #
  4.  
  5. scope :with_make, ->(make) { where(make: make) if make }
  6. scope :from_year, ->(min_year) { where('year >= ?', min_year) if min_year }
  7. scope :until_year, ->(max_year) { where('year <= ?', max_year) if max_year }
  8. scope :above_price, ->(min_selling_price) { where('selling_price >= ?', min_selling_price) if min_selling_price }
  9. scope :below_price, ->(max_selling_price) { where('selling_price <= ?', max_selling_price) if max_selling_price }
Add Comment
Please, Sign In to add comment