Rails select records with a date greater than or equal to zero

I have a Product model with an expired_at field. I want the query to return all products with an expired_at value that is greater than some value or equal to zero.

But I met problems 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 get these products in my request?

+5
source share
1 answer
 manufactured_at = Date.tomorrow Product.where("expired_at > ? OR expired_at IS NULL", manufactured_at) 

try it

+8
source

All Articles