如何将其转换为一个WHERE语句?我想查找房产是公寓的记录,也可以出售。
def apartment
@apartments_for_sale = Property.where(for_sale: true)
@real_apartments = @apartments_for_sale.where(apartment: true)
end
非常感谢!
答案 0 :(得分:2)
你应该可以这样做:
def apartment
@apartments = Property.where(for_sale: true, apartment: true)
#OR via method chaining:
@apartments = Property.where(for_sale: true).where(apartment: true)
end