Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

make default value for `:message` on `AM::Errors` explicit.

  • Loading branch information...
commit ca99ab2481d44d67bc392d0ec1125ff1439e9f94 1 parent 763635e
@senny senny authored
Showing with 2 additions and 4 deletions.
  1. +2 −4 activemodel/lib/active_model/errors.rb
View
6 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))
Please sign in to comment.
Something went wrong with that request. Please try again.