diff options
-rw-r--r-- | activemodel/README.rdoc | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/validator.rb | 2 | ||||
-rw-r--r-- | guides/source/active_record_validations.md | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc index f6beff14e1..0985f56bfb 100644 --- a/activemodel/README.rdoc +++ b/activemodel/README.rdoc @@ -219,7 +219,7 @@ behavior out of the box: class HasNameValidator < ActiveModel::Validator def validate(record) - record.errors[:name] = "must exist" if record.name.blank? + record.errors.messages[:name] << "must exist" if record.name.blank? end end diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index b98585912e..5752771d8c 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/activemodel/lib/active_model/validator.rb @@ -15,7 +15,7 @@ module ActiveModel # class MyValidator < ActiveModel::Validator # def validate(record) # if some_complex_logic - # record.errors[:base] = "This record is invalid" + # record.errors.messages[:base] << "This record is invalid" # end # end # diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md index de26a9bd6d..31c5b07a05 100644 --- a/guides/source/active_record_validations.md +++ b/guides/source/active_record_validations.md @@ -1078,7 +1078,7 @@ Another way to do this is using `[]=` setter ```ruby class Person < ActiveRecord::Base def a_method_used_for_validation_purposes - errors[:name] = "cannot contain the characters !@#%*()_-+=" + errors.messages[:name] << "cannot contain the characters !@#%*()_-+=" end end |