diff options
author | Angelo Capilleri <capilleri@yahoo.com> | 2012-08-03 17:12:27 +0200 |
---|---|---|
committer | Angelo Capilleri <capilleri@yahoo.com> | 2012-08-03 17:42:38 +0200 |
commit | 93b6fafe3c3197cdd8782b52e6152d58db685b1f (patch) | |
tree | be3e4e7cbc7b4fdcea54bea00c043b5db6e5409f /activemodel/lib | |
parent | 0c315c75a4bc16ee2e4aa9244e209d1f8aadc295 (diff) | |
download | rails-93b6fafe3c3197cdd8782b52e6152d58db685b1f.tar.gz rails-93b6fafe3c3197cdd8782b52e6152d58db685b1f.tar.bz2 rails-93b6fafe3c3197cdd8782b52e6152d58db685b1f.zip |
calculate errors_options one time in validate_each
errors_options is calculated for every *CHECKS* but it could be
calculated one time because options and RESERVED_OPTIONS
not change during this cycle
Diffstat (limited to 'activemodel/lib')
-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]] |