remove setting attribute to nil in validations when invalid to preserve before_type_cast value

This commit is contained in:
Adam Meehan
2008-07-30 12:22:06 +10:00
parent 037c3ea5c5
commit 8cad1b880e
2 changed files with 8 additions and 6 deletions

View File

@@ -72,14 +72,12 @@ module ValidatesTimeliness
column = record.column_for_attribute(attr_name)
begin
unless time = parse_date_time(raw_value, configuration[:type])
record.send("#{attr_name}=", nil)
record.errors.add(attr_name, configuration["invalid_#{configuration[:type]}_message".to_sym])
next
end
validate_timeliness_restrictions(record, attr_name, time, configuration)
rescue Exception => e
record.send("#{attr_name}=", nil)
rescue Exception => e
record.errors.add(attr_name, configuration["invalid_#{configuration[:type]}_message".to_sym])
end
end