【发布时间】:2014-04-11 14:56:44
【问题描述】:
此代码提取 foobar 为 Nil 的记录
Model.where(user_id: 14, foobar: nil)
如何使用相同的语法并获得 NOT nil?
类似:
Model.where(user_id: 14, foobar: !nil)
【问题讨论】:
标签: ruby-on-rails activerecord
此代码提取 foobar 为 Nil 的记录
Model.where(user_id: 14, foobar: nil)
如何使用相同的语法并获得 NOT nil?
类似:
Model.where(user_id: 14, foobar: !nil)
【问题讨论】:
标签: ruby-on-rails activerecord
Model.where(user_id: 14).where("foobar IS NOT NULL")
Model.where("user_id = ? AND foobar IS NOT ?", 14, nil)
【讨论】:
导轨 4:
Model.where(user_id: 14).where().not(foobar: nil)
Rails 3 - Rails where condition using NOT NULL
【讨论】:
where()