문제

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!

도움이 되었습니까?

해결책

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)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top