aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-07-16 15:21:25 +0900
committerGitHub <noreply@github.com>2018-07-16 15:21:25 +0900
commitcd84d8716497010464cc2fb14f6ac9fe12b7efb7 (patch)
tree8c78db25e9375163c27fcf812dc5e77fde22cbc0 /guides
parent94f2558f6a5bd315334d1b57a9aeeef48abfea20 (diff)
parent29ca7a1e0794a8b35f6a0858309920be25e99eda (diff)
downloadrails-cd84d8716497010464cc2fb14f6ac9fe12b7efb7.tar.gz
rails-cd84d8716497010464cc2fb14f6ac9fe12b7efb7.tar.bz2
rails-cd84d8716497010464cc2fb14f6ac9fe12b7efb7.zip
Merge pull request #33364 from lanzhiheng/fix-document-in-model-validator
Modify the expression's issue for `errors.add` document. [ci skip]
Diffstat (limited to 'guides')
-rw-r--r--guides/source/active_record_validations.md18
1 files changed, 0 insertions, 18 deletions
diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md
index c7846a0283..3c51313906 100644
--- a/guides/source/active_record_validations.md
+++ b/guides/source/active_record_validations.md
@@ -1133,24 +1133,6 @@ person.errors.full_messages
# => ["Name cannot contain the characters !@#%*()_-+="]
```
-An equivalent to `errors#add` is to use `<<` to append a message to the `errors.messages` array for an attribute:
-
-```ruby
- class Person < ApplicationRecord
- def a_method_used_for_validation_purposes
- errors.messages[:name] << "cannot contain the characters !@#%*()_-+="
- end
- end
-
- person = Person.create(name: "!@#")
-
- person.errors[:name]
- # => ["cannot contain the characters !@#%*()_-+="]
-
- person.errors.to_a
- # => ["Name cannot contain the characters !@#%*()_-+="]
-```
-
### `errors.details`
You can specify a validator type to the returned error details hash using the