diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-08-03 09:57:37 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-08-03 09:57:37 -0700 |
commit | 9895f6ca2b235873c26f9526760b096a7bc3e002 (patch) | |
tree | 753c3637bfa7499662f8e27948e9e63942397658 /activemodel | |
parent | c8a613b978df82aad8620f109b40f6027cb897a8 (diff) | |
parent | 93b6fafe3c3197cdd8782b52e6152d58db685b1f (diff) | |
download | rails-9895f6ca2b235873c26f9526760b096a7bc3e002.tar.gz rails-9895f6ca2b235873c26f9526760b096a7bc3e002.tar.bz2 rails-9895f6ca2b235873c26f9526760b096a7bc3e002.zip |
Merge pull request #7253 from acapilleri/lenght_validator_errors_options
calculate errors_options one time in validate_each
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/lib/active_model/validations/length.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb index aa72ea41c7..e4a1f9e80a 100644 --- a/activemodel/lib/active_model/validations/length.rb +++ b/activemodel/lib/active_model/validations/length.rb @@ -36,12 +36,12 @@ module ActiveModel def validate_each(record, attribute, value) value = tokenize(value) value_length = value.respond_to?(:length) ? value.length : value.to_s.length - + errors_options = options.except(*RESERVED_OPTIONS) + CHECKS.each do |key, validity_check| next unless check_value = options[key] next if value_length.send(validity_check, check_value) - errors_options = options.except(*RESERVED_OPTIONS) errors_options[:count] = check_value default_message = options[MESSAGES[key]] |