如何查询 Mongoid,'where is not null'?

How make a query in to Mongoid, 'where is not null'?

如何在 Mongoid 中进行查询,'where is not null'?例如

where('comment_id IS NOT NULL')

如何用 mongoid 制作它?

你可以使用$ne

来写
where(:comment_id.ne => nil)

相关documentation of queries.

你可以试试这个

Model.where(:comment_id.exists => true)