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

pestd · 2015年04月12日 · 最后由 prajnamas 回复于 2015年04月13日 · 1613 次阅读

请教,在 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)

需要 登录 后方可回复, 如果你还没有账号请 注册新账号