RoR, Can't iterate from DateTime/TimeWithZone
start = someModel.start_date.to_datetimefinish = someModel.end_date.to_datetimewhile(start < finish) do #bunch of awesome stuff start += 1.dayend
You must make sure that you are dealing with a Date
object (by calling to_date
), then everything works as expected:
start_date.to_date.upto(end_date.to_date) {|date| puts date }
Or with a range:
(start_date.to_date..end_date.to_date).to_a