mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
changed back to using error_value_formats for Rails 2.0/2.1
This commit is contained in:
parent
956933f58b
commit
f4ed751c26
@ -304,7 +304,7 @@ values inserted in the error messages for temporal restrictions like so
|
||||
|
||||
For Rails 2.0/2.1:
|
||||
|
||||
ValidatesTimeliness::Validator.default_error_value_formats.update(
|
||||
ValidatesTimeliness::Validator.error_value_formats.update(
|
||||
:time => '%H:%M:%S',
|
||||
:date => '%Y-%m-%d',
|
||||
:datetime => '%Y-%m-%d %H:%M:%S'
|
||||
|
||||
@ -38,7 +38,7 @@ module ValidatesTimeliness
|
||||
errors = defaults['activerecord']['errors']['messages'].inject({}) {|h,(k,v)| h[k.to_sym] = v.gsub(/\{\{\w*\}\}/, '%s');h }
|
||||
::ActiveRecord::Errors.default_error_messages.update(errors)
|
||||
|
||||
ValidatesTimeliness::Validator.default_error_value_formats = defaults['validates_timeliness']['error_value_formats'].symbolize_keys
|
||||
ValidatesTimeliness::Validator.error_value_formats = defaults['validates_timeliness']['error_value_formats'].symbolize_keys
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -2,8 +2,6 @@ module ValidatesTimeliness
|
||||
|
||||
class Validator
|
||||
cattr_accessor :ignore_restriction_errors
|
||||
cattr_accessor :default_error_value_formats
|
||||
|
||||
self.ignore_restriction_errors = false
|
||||
|
||||
RESTRICTION_METHODS = {
|
||||
@ -163,10 +161,14 @@ module ValidatesTimeliness
|
||||
if defined?(I18n)
|
||||
I18n.translate('validates_timeliness.error_value_formats')
|
||||
else
|
||||
default_error_value_formats
|
||||
@@error_value_formats
|
||||
end
|
||||
end
|
||||
|
||||
def error_value_formats=(formats)
|
||||
@@error_value_formats = formats
|
||||
end
|
||||
|
||||
def evaluate_option_value(value, type, record)
|
||||
case value
|
||||
when Time, Date
|
||||
|
||||
@ -563,8 +563,8 @@ describe ValidatesTimeliness::Validator do
|
||||
if defined?(I18n)
|
||||
I18n.backend.store_translations 'en', :validates_timeliness => { :error_value_formats => custom }
|
||||
else
|
||||
@@formats = ValidatesTimeliness::Validator.default_error_value_formats
|
||||
ValidatesTimeliness::Validator.default_error_value_formats = custom
|
||||
@@formats = ValidatesTimeliness::Validator.error_value_formats
|
||||
ValidatesTimeliness::Validator.error_value_formats = custom
|
||||
end
|
||||
end
|
||||
|
||||
@ -590,7 +590,7 @@ describe ValidatesTimeliness::Validator do
|
||||
if defined?(I18n)
|
||||
I18n.reload!
|
||||
else
|
||||
ValidatesTimeliness::Validator.default_error_value_formats = @@formats
|
||||
ValidatesTimeliness::Validator.error_value_formats = @@formats
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user