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

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -