diff options
author | Abdelkader Boudih <terminale@gmail.com> | 2015-02-20 14:57:51 +0000 |
---|---|---|
committer | Abdelkader Boudih <terminale@gmail.com> | 2015-02-20 14:57:51 +0000 |
commit | 9a04558593d6926a68ab093b84d1fd3d357fc61f (patch) | |
tree | d2c6abc194e4fbbc03cf1b8ca023f18e681bbe5b /activemodel | |
parent | 9a476b8cd6724699027eb00ec7ffa8b232d1b734 (diff) | |
parent | 66e2e19bc03d4dc5f775848ceedb33ada75a7ace (diff) | |
download | rails-9a04558593d6926a68ab093b84d1fd3d357fc61f.tar.gz rails-9a04558593d6926a68ab093b84d1fd3d357fc61f.tar.bz2 rails-9a04558593d6926a68ab093b84d1fd3d357fc61f.zip |
Merge pull request #19013 from y-yagi/custom_validators_example
use `messages` instead of deprecated `ActiveModel::Errors#[]=` method [ci skip]
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/README.rdoc | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/validator.rb | 2 |
2 files changed, 2 insertions, 2 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 # |