aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_record_validations.md
diff options
context:
space:
mode:
authorRadu Busuioc <ra.busuioc@gmail.com>2013-05-16 18:46:00 +0100
committerRadu Busuioc <ra.busuioc@gmail.com>2013-05-16 18:46:00 +0100
commit5554775980b27b64a5ae5810cabc4886776b9206 (patch)
tree12132ca996d2ee811e17be6fe1fe6b974c66b99a /guides/source/active_record_validations.md
parent8f901dee9e2072dd20e0a252a89dd501d783d85b (diff)
downloadrails-5554775980b27b64a5ae5810cabc4886776b9206.tar.gz
rails-5554775980b27b64a5ae5810cabc4886776b9206.tar.bz2
rails-5554775980b27b64a5ae5810cabc4886776b9206.zip
Corrected documentation regarding validation errors
Diffstat (limited to 'guides/source/active_record_validations.md')
-rw-r--r--guides/source/active_record_validations.md14
1 files changed, 7 insertions, 7 deletions
diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md
index dfc951f10e..621d2222ff 100644
--- a/guides/source/active_record_validations.md
+++ b/guides/source/active_record_validations.md
@@ -162,8 +162,8 @@ Person.create(name: nil).valid? # => false
```
After Active Record has performed validations, any errors found can be accessed
-through the `errors` instance method, which returns a collection of errors. By
-definition, an object is valid if this collection is empty after running
+through the `errors.messages` instance method, which returns a collection of errors.
+By definition, an object is valid if this collection is empty after running
validations.
Note that an object instantiated with `new` will not report errors even if it's
@@ -176,17 +176,17 @@ end
>> p = Person.new
#=> #<Person id: nil, name: nil>
->> p.errors
+>> p.errors.messages
#=> {}
>> p.valid?
#=> false
->> p.errors
+>> p.errors.messages
#=> {name:["can't be blank"]}
>> p = Person.create
#=> #<Person id: nil, name: nil>
->> p.errors
+>> p.errors.messages
#=> {name:["can't be blank"]}
>> p.save
@@ -993,12 +993,12 @@ end
person = Person.new
person.valid? # => false
-person.errors
+person.errors.messages
# => {:name=>["can't be blank", "is too short (minimum is 3 characters)"]}
person = Person.new(name: "John Doe")
person.valid? # => true
-person.errors # => []
+person.errors.messages # => {}
```
### `errors[]`