From d6cbb27e7b260c970bf7d07dc0b0591ed82cee2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 15 May 2010 21:55:16 +0200 Subject: Revert "Make ActiveModel::Errors#add_on_blank and #add_on_empty accept an options hash and make various Validators pass their (filtered) options." Having a huge array to whitelist options is not the proper way to handle this case. This means that the ActiveModel::Errors object should know about the options given in *all* validators and break the extensibility added by the validators itself. If the intent is to whitelist options before sending them to I18n, each validator should clean its respective options instead of throwing the responsibility to the Errors object. This reverts commit bc1c8d58ec45593acba614d1d0fecb49adef08ff. --- activemodel/lib/active_model/validations/length.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activemodel/lib/active_model/validations/length.rb') diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb index 9b671f58de..d7218f4f52 100644 --- a/activemodel/lib/active_model/validations/length.rb +++ b/activemodel/lib/active_model/validations/length.rb @@ -37,7 +37,7 @@ module ActiveModel CHECKS.each do |key, validity_check| next unless check_value = options[key] - options[:message] ||= options[MESSAGES[key]] if options[MESSAGES[key]] + custom_message = options[:message] || options[MESSAGES[key]] valid_value = if key == :maximum value.nil? || value.size.send(validity_check, check_value) @@ -46,7 +46,7 @@ module ActiveModel end next if valid_value - record.errors.add(attribute, MESSAGES[key], options.merge(:count => check_value)) + record.errors.add(attribute, MESSAGES[key], :default => custom_message, :count => check_value) end end end -- cgit v1.2.3