modified conversion for rails <= 2.0.2 to be faster usign schema

conversion methods
This commit is contained in:
Adam Meehan
2008-05-21 11:01:41 +10:00
parent 7fadc2c164
commit d3b126729b

View File

@@ -91,9 +91,11 @@ module ValidatesTimeliness
return cached if cached && !reload return cached if cached && !reload
time = read_attribute_before_type_cast('#{attr_name}') time = read_attribute_before_type_cast('#{attr_name}')
unless time.acts_like?(:time) unless time.acts_like?(:time)
# check invalid date klass = ActiveRecord::ConnectionAdapters::Column
time.to_date rescue time = nil # check for invalid date
time = time.to_time if time time = nil unless klass.string_to_date(time)
# convert to time if still valid
time = klass.string_to_time(time) if time
end end
@attributes_cache['#{attr_name}'] = time @attributes_cache['#{attr_name}'] = time
end end