Question

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!

Was it helpful?

Solution

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)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top