aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-02-01 16:58:29 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2015-02-01 16:58:29 -0800
commit83c19734fbaeb644d46a4dcc197c941841c4e268 (patch)
treef91555ce55e52110d6fc7df6401aa13e227137ee /activemodel/lib/active_model
parent226cd8a094c81edb72143173e4d0c88a2eb01d5f (diff)
parent27aa4dda7d89ce7332e6d1f3266c3a0cf1c3fb9e (diff)
downloadrails-83c19734fbaeb644d46a4dcc197c941841c4e268.tar.gz
rails-83c19734fbaeb644d46a4dcc197c941841c4e268.tar.bz2
rails-83c19734fbaeb644d46a4dcc197c941841c4e268.zip
Merge pull request #18612 from eileencodes/fix-validates-on-associated-record-if-parent-is-validate-false
Fix validations on child record when record parent has validate: false
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/validator.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb
index ac32750946..b98585912e 100644
--- a/activemodel/lib/active_model/validator.rb
+++ b/activemodel/lib/active_model/validator.rb
@@ -163,6 +163,10 @@ module ActiveModel
# +ArgumentError+ when invalid options are supplied.
def check_validity!
end
+
+ def should_validate?(record) # :nodoc:
+ !record.persisted? || record.changed? || record.marked_for_destruction?
+ end
end
# +BlockValidator+ is a special +EachValidator+ which receives a block on initialization