Select where not null or empty in mongoid Select where not null or empty in mongoid ruby-on-rails ruby-on-rails

Select where not null or empty in mongoid


Try

Model.where(:url.ne => "", :url.exists => true).count

see Mongoid Symbol Operators


Try

Model.where(:url.nin => ["", nil]).count

It works even when url = nil


Try:

Model.nin(url: ['', nil])