diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-06-27 05:16:38 -0700 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-06-27 05:16:38 -0700 |
commit | 48ab2c06e0c246aae4a36d73b4aeac00d928be02 (patch) | |
tree | 79594c69cb4577b99dd35436e2ab6f6921bb0135 /activemodel/lib | |
parent | 666ca163e0243bd466bebf54f8c29ac43bf29235 (diff) | |
parent | ca99ab2481d44d67bc392d0ec1125ff1439e9f94 (diff) | |
download | rails-48ab2c06e0c246aae4a36d73b4aeac00d928be02.tar.gz rails-48ab2c06e0c246aae4a36d73b4aeac00d928be02.tar.bz2 rails-48ab2c06e0c246aae4a36d73b4aeac00d928be02.zip |
Merge pull request #11054 from senny/11048_make_default_value_explicit
make default value for `:message` on `AM::Errors` explicit.
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 0d7efab04b..9341f689de 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -289,7 +289,7 @@ module ActiveModel # # => NameIsInvalid: name is invalid # # person.errors.messages # => {} - def add(attribute, message = nil, options = {}) + def add(attribute, message = :invalid, options = {}) message = normalize_message(attribute, message, options) if exception = options[:strict] exception = ActiveModel::StrictValidationFailed if exception == true @@ -331,7 +331,7 @@ module ActiveModel # # person.errors.add :name, :blank # person.errors.added? :name, :blank # => true - def added?(attribute, message = nil, options = {}) + def added?(attribute, message = :invalid, options = {}) message = normalize_message(attribute, message, options) self[attribute].include? message end @@ -437,8 +437,6 @@ module ActiveModel private def normalize_message(attribute, message, options) - message ||= :invalid - case message when Symbol generate_message(attribute, message, options.except(*CALLBACKS_OPTIONS)) |