以下finder打印出IS NULL.
User.where(:id =>nil) #=> []
User Load (0.5ms) SELECT `users`.* FROM `users` WHERE `users`.`id` IS NULL ORDER BY created_at DESC
但是我找不到如何打印IS NOT NULL?
最简单的惯用ActiveRecord
解决方案:
User.where.not(id: nil)
原文链接:https://www.f2er.com/ruby/272397.html