【问题标题】:Rails Active Record where object has an Attribute对象具有属性的 Rails Active Record
【发布时间】:2014-04-20 06:54:13
【问题描述】:

我正在尝试做类似...

self.where(active: true, latitude: !nil)

这不起作用。我基本上需要一些东西来查询具有纬度属性的对象,该属性具有值。谢谢!

【问题讨论】:

    标签: ruby-on-rails activerecord where


    【解决方案1】:

    类似的方法也可以

    self.where("active = ? AND latitude IS NOT ?", true, nil)
    

    导轨 4 路

    self.where(active: true).where().not(latitude: nil)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-18
      相关资源
      最近更新 更多