diff options
author | José Valim <jose.valim@gmail.com> | 2010-05-15 21:55:16 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-05-15 21:55:16 +0200 |
commit | d6cbb27e7b260c970bf7d07dc0b0591ed82cee2a (patch) | |
tree | ccd57aa2f19b43943ae6fb8e34fbb34b3a673726 /activerecord/lib | |
parent | f055bc05d515b80c89b99b775546b954f270bc5c (diff) | |
download | rails-d6cbb27e7b260c970bf7d07dc0b0591ed82cee2a.tar.gz rails-d6cbb27e7b260c970bf7d07dc0b0591ed82cee2a.tar.bz2 rails-d6cbb27e7b260c970bf7d07dc0b0591ed82cee2a.zip |
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.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/validations/associated.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/validations/uniqueness.rb | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/validations/associated.rb b/activerecord/lib/active_record/validations/associated.rb index 0b0f5682aa..e41635134c 100644 --- a/activerecord/lib/active_record/validations/associated.rb +++ b/activerecord/lib/active_record/validations/associated.rb @@ -3,7 +3,7 @@ module ActiveRecord class AssociatedValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return if (value.is_a?(Array) ? value : [value]).collect{ |r| r.nil? || r.valid? }.all? - record.errors.add(attribute, :invalid, options.merge(:value => value)) + record.errors.add(attribute, :invalid, :default => options[:message], :value => value) end end diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb index f2561075e8..6283bdd0d6 100644 --- a/activerecord/lib/active_record/validations/uniqueness.rb +++ b/activerecord/lib/active_record/validations/uniqueness.rb @@ -32,7 +32,7 @@ module ActiveRecord end if relation.exists? - record.errors.add(attribute, :taken, options.merge(:value => value)) + record.errors.add(attribute, :taken, :default => options[:message], :value => value) end end |