Domanda

I'm trying to do something like...

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

this doesn't work. I basically need something that queries for objects who HAVE a latitude property which has a value. Thanks!

È stato utile?

Soluzione

something like this also works

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

OR

Rails 4 way

self.where(active: true).where().not(latitude: nil)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top