Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added information about the new Object#invalid? method just added to …

…Edge.
  • Loading branch information...
commit 2bf922d056eb41d709f451580df6175425448ecb 1 parent 336f0a2
Trevor Turk authored
View
6 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
Please sign in to comment.
Something went wrong with that request. Please try again.