From 2bf922d056eb41d709f451580df6175425448ecb Mon Sep 17 00:00:00 2001 From: Trevor Turk Date: Sun, 8 Mar 2009 13:04:23 -0500 Subject: Added information about the new Object#invalid? method just added to Edge. --- railties/guides/source/activerecord_validations_callbacks.textile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'railties/guides/source') 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 -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. class Person < ActiveRecord::Base -- cgit v1.2.3