aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source
diff options
context:
space:
mode:
authorTrevor Turk <trevorturk@yahoo.com>2009-03-08 13:04:23 -0500
committerTrevor Turk <trevorturk@yahoo.com>2009-03-08 13:04:23 -0500
commit2bf922d056eb41d709f451580df6175425448ecb (patch)
tree435f1e5de540126bec2113dffd014057f66a853b /railties/guides/source
parent336f0a2e63cc79dad69c849fda82a5bf81609076 (diff)
downloadrails-2bf922d056eb41d709f451580df6175425448ecb.tar.gz
rails-2bf922d056eb41d709f451580df6175425448ecb.tar.bz2
rails-2bf922d056eb41d709f451580df6175425448ecb.zip
Added information about the new Object#invalid? method just added to Edge.
Diffstat (limited to 'railties/guides/source')
-rw-r--r--railties/guides/source/activerecord_validations_callbacks.textile6
1 files changed, 5 insertions, 1 deletions
diff --git a/railties/guides/source/activerecord_validations_callbacks.textile b/railties/guides/source/activerecord_validations_callbacks.textile
index e92805aede..20870f5d4e 100644
--- a/railties/guides/source/activerecord_validations_callbacks.textile
+++ b/railties/guides/source/activerecord_validations_callbacks.textile
@@ -137,7 +137,11 @@ end
=> ActiveRecord::RecordInvalid: Validation failed: Name can't be blank
</ruby>
-To verify whether or not a particular attribute of an object is valid, you can use the +invalid?+ method. This method is only useful _after_ validations have been run, because it only inspects the errors collection and does not trigger validations itself. It's different from the +valid?+ method because it doesn't verify the validity of the object as a whole, but only if there are errors found on an individual attribute of the object.
++Object#invalid?+ is simply the inverse of +Object#valid?+. +invalid?+ triggers your validations and returns true if any errors were added to the object, and false otherwise.
+
+h3. +errors.invalid?+
+
+To verify whether or not a particular attribute of an object is valid, you can use the +errors.invalid?+ method. This method is only useful _after_ validations have been run, because it only inspects the errors collection and does not trigger validations itself. It's different from the +valid?+ method because it doesn't verify the validity of the object as a whole, but only if there are errors found on an individual attribute of the object.
<ruby>
class Person < ActiveRecord::Base