Permalink
Browse files

Merge pull request #11054 from senny/11048_make_default_value_explicit

make default value for `:message` on `AM::Errors` explicit.
  • Loading branch information...
2 parents 666ca16 + ca99ab2 commit 48ab2c06e0c246aae4a36d73b4aeac00d928be02 @carlosantoniodasilva carlosantoniodasilva committed Jun 27, 2013
Showing with 2 additions and 4 deletions.
  1. +2 −4 activemodel/lib/active_model/errors.rb
@@ -289,7 +289,7 @@ def to_hash(full_messages = false)
# # => 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 @@ def add_on_blank(attributes, options = {})
#
# 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 @@ def generate_message(attribute, type = :invalid, options = {})
private
def normalize_message(attribute, message, options)
- message ||= :invalid
-
case message
when Symbol
generate_message(attribute, message, options.except(*CALLBACKS_OPTIONS))

0 comments on commit 48ab2c0

Please sign in to comment.