【发布时间】:2014-12-21 23:34:23
【问题描述】:
我正在尝试搜索帖子值是 false 还是 nil。
Post.where.not(:top_card => true)
这只会返回错误值。我已经确认,如果我执行以下任一操作,它会返回正确的值
Post.where(:top_card => false)
或
Post.where(:top_card => nil)
知道如何获取 nil 和 false 值的帖子吗?
我是否使用了错误的搜索方法?
【问题讨论】:
-
试试
Post.where(top_card: [false, nil]。 -
@Vucko 效果很好,[] 是如何工作的?它是否将它视为一个数组,它只是迭代查找所有值?另外,如果您将其作为答案提交,我将使其正确
标签: ruby-on-rails ruby where