I want to get date range between from and till in Rails seed.
When I try to generate date range ((Date.today – 10)..Date.today) exception occurred.
Exception message: bad value for range
But in the Rails Console everything all right.
I think ActiveSupport are reasonable for that (my debugger told me that).
Ralls 3.1.3
What’s going on?
You can understand what’s going on by splitting the two edges and check their class like so:
The error you’re experiencing is something like this:
Can you post the classes of your 2 edges of the range?
Have you overwritten any class in your rails environment? Does it work in
irb?PS: As you’re in rails you can use
10.days.agobut you’ll need to useto_dateas it’s aActiveSupport::TimeWithZone