Rails 哪里不存在

Rails where not exists

有什么简写的方法吗?

Person.where.not(age: 10).exists?

我不知道怎么写Person.exists?(年龄不是10岁) 谢谢

您可以使用“原始”SQL 作为 ActiveRecord where.not:

Person.exists?(['age != ?', 10])