I have a Car model like this.
class Car < ActiveRecord::Base
scope :modern, -> do
where(make_date: 2018)
end
scope :black, -> do
where(color: :black)
end
scope :bmw, -> do
where(make: :bmw)
end
end
I can find all modern cars by Car.modern
.
I can find all black cars by Car.black
.
I can find all BMW cars by Car.bmw
.
How do I use these named scopes to find all cars that are either 'black' or 'modern' ? So that i can have Old-Black-Nissan, Modern-White-BMW, Moder-black-Ford all in a single resultset.
Using Rails 4.2.8