创建: 2017/08/13
other_type_car = Car.joins(:car_type).active.find_by(car_type:
car_type)
car_type)
@recommend_cars =
Car.joins(:region).active.where('regions.region_name = :region_name
AND total_price >= :bottom AND total_price <= :top',
region_name: @car.region.region_name, bottom: @car.total_price -
300_000, top: @car.total_price + 300_000)
Car.joins(:region).active.where('regions.region_name = :region_name
AND total_price >= :bottom AND total_price <= :top',
region_name: @car.region.region_name, bottom: @car.total_price -
300_000, top: @car.total_price + 300_000)
注意: 是joins, 搜索条件里用复数
Model.joins(:sample).where('samples.item = :item', item:
123)
123)