I have a shipment model with a method called returnable?
If a shipment has been delivered, it figures out what the last
returnable date is, delivery date + 14 days.
In Shipment Model
n = Time.now.to_i.abs.round
d = last_return_date.to_i.abs.round
if d >= n
This works great on the intials edit view, but if the form is submitted
and there is a validation error, it gives the following error message:
NoMethodError in Shipments#update
undefined method `to_i’ for #<Date: 4910233/2,0,2299161>
Just wondering what’s up?
Both the update action and edit action grab the @shipment instance var
the same way, so this should totally work.
If I’m just a noob over complicating the “is this date greater than this
date” thing and there’s a better way to write that, please feel free to
Any help is appreciated.