新手问题 where 多条件组合问题

pestd · April 12, 2015 · Last by prajnamas replied at April 13, 2015 · 1613 hits

请教,在 conditions.store(:date, params[:date]) @saledatas = Saledata.where(conditions).order('id DESC').page(params[:page])

基础上,多加一个 col1 IS NOT NULL , 咋写啊?

你可以像写 SQL 一样任意写 where 语句的:

date = Date.parse(params[:date])
where("date = ? AND col1 IS NOT NULL", date)

where.not(col1 :nil)

You need to Sign in before reply, if you don't have an account, please Sign up first.