mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 07:16:41 +00:00
modified conversion for rails <= 2.0.2 to be faster usign schema
conversion methods
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user