ruby - Rails Activerecord Ambiguous column name on .joins -
here code. work fine if have in :search field or if have in :supplier field if have in both "ambiguous column name 'number'". there way select or something?
@date_from = params[:date_from] || date.today.beginning_of_month.strftime('%m/%d/%y') @date_to = params[:date_to] || date.today.strftime('%m/%d/%y') q = "%#{params[:search]}%" @products = product.where("discont = ? , nonproduct = ?" ,0,0) @products = @products.where('number ?' ,q) if params[:search].present? @products = @products.joins(:supplier_items).where('supplier = ?' ,params[:supplier]) if params[:supplier].present? @products = @products.paginate(page: params[:page], per_page: 25)
just prefix number table name
for example:
@products = product.where(:discount => 0, :nonproduct => 0) @products = @products.where('products.number ?', query)
Comments
Post a Comment