aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorBrent Wheeldon & Nick Monje <pair+brent+nmonje@pivotallabs.com>2012-06-22 12:09:48 -0400
committerBen Moss <pair+bmoss@pivotallabs.com>2012-07-20 17:37:57 -0400
commit9feda929409ab687befaed8d1c9878d94e955adc (patch)
tree5deafb5e134315050c59e059a71d18ec6915e655 /guides
parent215d41d802637520129cb7551b35faca72873143 (diff)
downloadrails-9feda929409ab687befaed8d1c9878d94e955adc.tar.gz
rails-9feda929409ab687befaed8d1c9878d94e955adc.tar.bz2
rails-9feda929409ab687befaed8d1c9878d94e955adc.zip
AR has a subclass of AM:PresenceValidator.
This allows us to mark the parent object as invalid if all associated objects in a presence validated association are marked for destruction. See: https://github.com/rails/rails/issues/6812
Diffstat (limited to 'guides')
-rw-r--r--guides/source/active_record_validations_callbacks.textile2
1 files changed, 2 insertions, 0 deletions
diff --git a/guides/source/active_record_validations_callbacks.textile b/guides/source/active_record_validations_callbacks.textile
index f49d91fd3c..da3a96d84e 100644
--- a/guides/source/active_record_validations_callbacks.textile
+++ b/guides/source/active_record_validations_callbacks.textile
@@ -373,6 +373,8 @@ class LineItem < ActiveRecord::Base
end
</ruby>
+If you validate the presence of an object associated via a +has_one+ or +has_many+ relationship, it will check that the object is neither +blank?+ nor +marked_for_destruction?+.
+
Since +false.blank?+ is true, if you want to validate the presence of a boolean field you should use <tt>validates :field_name, :inclusion => { :in => [true, false] }</tt>.
The default error message is "_can't be empty_".