我使用此查询计算我的表Notifications
上的记录:
Notifications.where.not(status: 'closed').count
Notifications.where.not(status: "closed").count
Notifications.where("status != ?", "closed").count
我有1个状态为closed
的数据,所以如果我运行该查询,它会给出:
2.1.0 :024 > Notification.where("status != ?", "closed").count
(0.1ms) SELECT COUNT(*) FROM `notifications` WHERE (status != 'closed')
=> 99 (because I have 100 records)
2.1.0 :025 >
但是,它显示0
(零)
我该如何解决这个问题。