Skip to content
Advertisement

Tag: rails-activerecord

Where with OR condition for the same column in Rails

I’m trying to retrieve all records that have expired_at as nil and expired_at greater than the current time. I’ve tried this: But that is only returning me the records expired_at greater than DateTime.now. Why is the nil being neglected? Answer Your current query checks that expired_at is equal to null (via = NULL) which will not evaluate to true. Instead,

Advertisement