Comparison of Date with nil failed - ruby
3 answers
Another option is to convert both to integer
if valid_from.to_i > Date.today.to_i
(nil converts to 0 and never exceeds the current date)
The advantage is that it is shorter and does not need treatment for an additional case. Disadvantage: Failure at the beginning of the second stage (may be negligible for a large number of scenarios)
+2
source to share