diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc index f6beff14e1f0a46f24dcd954806c68c7658000c7..0985f56bfb377ff0596567f333485e764a246c0a 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 b98585912e3729861767a07fea5052c200a41346..5752771d8ce848845b6f186bcb7a2f5e1497faa7 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 de26a9bd6db1f392b01ef155e039403aedc8f544..31c5b07a05bf447b29de3b8c02e11d56a7546ed8 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