我知道有更新版本的activerecord有Model.where.not。旧版本的activerecord是否有解决方法?
我想做Model.where.not(:completed_at => nil)
其中completed_at
是时间戳值。
答案 0 :(得分:3)
你可以使用arel,但它有点冗长
Model.where(Model.arel_table[:completed_at].not_eq(nil))
否则转到原始SQL
Model.where('completed_at IS NOT NULL')