diff options
author | Subba Rao Pasupuleti <subbarao.pasupuleti@gmail.com> | 2010-08-04 11:04:41 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-08-12 13:12:03 -0300 |
commit | e82b38cd578aa316a03dae55df8076c4b2111bb6 (patch) | |
tree | 9acc226e5b34c389a9ede5b16cb938de0b768fa9 | |
parent | 90a7915ab2cf29bebf2e7c4f67eb39e23278efd5 (diff) | |
download | rails-e82b38cd578aa316a03dae55df8076c4b2111bb6.tar.gz rails-e82b38cd578aa316a03dae55df8076c4b2111bb6.tar.bz2 rails-e82b38cd578aa316a03dae55df8076c4b2111bb6.zip |
tidy up validations length code [#5297 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
-rw-r--r-- | activemodel/lib/active_model/validations/length.rb | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb index a7af4f2b4d..ecae73a66e 100644 --- a/activemodel/lib/active_model/validations/length.rb +++ b/activemodel/lib/active_model/validations/length.rb @@ -41,13 +41,9 @@ module ActiveModel CHECKS.each do |key, validity_check| next unless check_value = options[key] - valid_value = if key == :maximum - value.nil? || value.size.send(validity_check, check_value) - else - value && value.size.send(validity_check, check_value) - end + value ||= [] if key == :maximum - next if valid_value + next if value && value.size.send(validity_check, check_value) errors_options = options.except(*RESERVED_OPTIONS) errors_options[:count] = check_value |