diff options
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/CHANGELOG.md | 5 | ||||
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 13 | ||||
-rw-r--r-- | activemodel/lib/active_model/locale/en.yml | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/validations/absence.rb | 4 | ||||
-rw-r--r-- | activemodel/lib/active_model/validator.rb | 2 |
5 files changed, 4 insertions, 22 deletions
diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md index b1d33c8692..09e6ede064 100644 --- a/activemodel/CHANGELOG.md +++ b/activemodel/CHANGELOG.md @@ -19,11 +19,6 @@ *Roberto Vasquez Angel* -* Added `ActiveModel::Errors#add_on_present` method. Adds error messages to - present attributes. - - *Roberto Vasquez Angel* - * `[attribute]_changed?` now returns `false` after a call to `reset_[attribute]!` *Renato Mascarenhas* diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index b713e99e25..963e52bff3 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -328,19 +328,6 @@ module ActiveModel end end - # Will add an error message to each of the attributes in +attributes+ that - # is present (using Object#present?). - # - # person.errors.add_on_present(:name) - # person.errors.messages - # # => { :name => ["must be blank"] } - def add_on_present(attributes, options = {}) - Array(attributes).flatten.each do |attribute| - value = @base.send(:read_attribute_for_validation, attribute) - add(attribute, :not_blank, options) if value.present? - end - end - # Returns +true+ if an error on the attribute with the given message is # present, +false+ otherwise. +message+ is treated the same as for +add+. # diff --git a/activemodel/lib/active_model/locale/en.yml b/activemodel/lib/active_model/locale/en.yml index 8ea34b84f5..540e8132d3 100644 --- a/activemodel/lib/active_model/locale/en.yml +++ b/activemodel/lib/active_model/locale/en.yml @@ -13,7 +13,7 @@ en: accepted: "must be accepted" empty: "can't be empty" blank: "can't be blank" - not_blank: "must be blank" + present: "must be blank" too_long: "is too long (maximum is %{count} characters)" too_short: "is too short (minimum is %{count} characters)" wrong_length: "is the wrong length (should be %{count} characters)" diff --git a/activemodel/lib/active_model/validations/absence.rb b/activemodel/lib/active_model/validations/absence.rb index 6790554907..1a1863370b 100644 --- a/activemodel/lib/active_model/validations/absence.rb +++ b/activemodel/lib/active_model/validations/absence.rb @@ -2,8 +2,8 @@ module ActiveModel module Validations # == Active Model Absence Validator class AbsenceValidator < EachValidator #:nodoc: - def validate(record) - record.errors.add_on_present(attributes, options) + def validate_each(record, attr_name, value) + record.errors.add(attr_name, :present, options) if value.present? end end diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index ff3dfa01c8..d51f4d1936 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/activemodel/lib/active_model/validator.rb @@ -110,7 +110,7 @@ module ActiveModel # Return the kind for this validator. # # PresenceValidator.new.kind # => :presence - # UniquenessValidator.new.kind # => :uniqueness + # UniquenessValidator.new.kind # => :uniqueness def kind self.class.kind end |