I'm creating a scope in my rails app, I want my scope to return documents which have anything set for the field in question.
scope :address_available, where(:address => "")
So because some documents might not have that field defined, and others will have a string as the value. But how can I return the documents which are not nil
?
Use exists
scope :address_available, where(:address.exists => true)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With