I have a Product
model with expired_at
date field. I want query which return all products with expired_at
value that bigger than some value or equals to nil.
But I met a troubles here:
manufactured_at = Date.tomorrow
Product.where('expired_at > ? OR expired_at = NULL', manufactured_at)
# => ActiveRecord::Relation []
Product.all
# => Product id: 1, expired_at: nil, Product id; 2, expired_at: nil, ...
How can I fetch these products in my query?
manufactured_at = Date.tomorrow
Product.where("expired_at > ? OR expired_at IS NULL", manufactured_at)
try this
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