我可以在RoR 4中发表如下声明:
@vendors = Vendor.includes(:business).where(:business_id=>@business.id,:city_id=>city,:activated=>"1",["business.business_name LIKE ?","%#{params[:search]}%"]).page(params[:page]).per_page(10)
如果没有,那我该怎么办?
答案 0 :(得分:1)
不,你不能这样做,但你可以链接.where()
个电话,即。
.where(business_id: @business.id).where("businesses.business_name LIKE ?", "%#{params[:search]}%")
请注意,您需要包含.references(:business)
才能确保执行LEFT JOIN
:
Vendor.includes(:business).references(:business).where(business_id:@business.id, etc..).where('businesses.business_name LIKE ?", "%#{params[:search]}%")