6uvcog
Last Updated: February 25, 2016
·
509
· sheerun
Photo on 08.01.2013 at 04.15

Don't use include? for checking if Date is in Range

Following will instantiate every date between start_date and end_date, and then check if date is in that set:

(start_date..end_date).include?(date)

That could take a while. Instead use:

(start_date..end_date).cover?(date)

It uses >= and '<=' methods on Range boundaries.