These days I have been having trouble with a test that tried to test
DateTime functionality. I have discovered that a NULL DateTime is
auto-type casted to NIL by Rails.
My problem here is that I have a field :datetime and I want to allow
NULL datetimes but not wrong datetimes. With this validation if deadline
is wrong or if is is blank it returns true. How I can accomplish this?
dt = DateTime.parse(deadline.to_s)
errors.add(:deadline, "Deadline has invalid syntax")