【问题标题】:Rails 4 to where.not and ORRails 4 到 where.not 和 OR
【发布时间】:2014-09-23 09:11:08
【问题描述】:

试图重写这个子句:

where("authorized_at IS NOT NULL OR paid_at IS NOT NULL")

给那个更漂亮的人:

where.not(authorized_at: nil, paid_at: nil)

但这会产生“authorized_at IS NOT NULL ANDpaid_at IS NOT NULL”。有没有办法用 where.not 重写?

【问题讨论】:

    标签: ruby-on-rails-4 rails-activerecord where-clause


    【解决方案1】:

    我能得到的最好的结果是:

    where.not("authorized_at IS NULL AND paid_at IS NULL")
    

    奇怪的是,hash 对应项的工作方式不同......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-30
      相关资源
      最近更新 更多