The following finder prints out IS NULL
.
User.where(:id =>nil) #=> []
User Load (0.5ms) SELECT `users`.* FROM `users` WHERE `users`.`id` IS NULL ORDER BY created_at DESC
But I couldn't find how to print out IS NOT NULL
one?
Try User.where("id IS NOT NULL")
This should do your job
The simplest, idiomatic ActiveRecord solution:
User.where.not(id: nil)
User.where.not(id: nil)
will work for rails 4.
User.where("id IS NOT NULL")
will work for older versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With