From e82b38cd578aa316a03dae55df8076c4b2111bb6 Mon Sep 17 00:00:00 2001 From: Subba Rao Pasupuleti Date: Wed, 4 Aug 2010 11:04:41 -0400 Subject: [PATCH] tidy up validations length code [#5297 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activemodel/lib/active_model/validations/length.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb index a7af4f2b4d6..ecae73a66e1 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