aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorEric Chahin <erc73@cornell.edu>2014-05-01 02:38:15 -0400
committerEric Chahin <erc73@cornell.edu>2014-05-01 03:27:24 -0400
commitc6d685ba1118cc1f6303122117df945ebe8fceae (patch)
treeb9d3b46fc5b454d8b8089411182da5cf936332c2 /activerecord/lib
parent876155705b56e66a8b9ed96f7b79d1c8d1763200 (diff)
downloadrails-c6d685ba1118cc1f6303122117df945ebe8fceae.tar.gz
rails-c6d685ba1118cc1f6303122117df945ebe8fceae.tar.bz2
rails-c6d685ba1118cc1f6303122117df945ebe8fceae.zip
Fixed custom validation context bug where child
associations were not being saved. Fixes #13854. [Eric Chahin, Aaron Nelson, & Kevin Casey]
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/autosave_association.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb
index f149d8f127..a30e5e4579 100644
--- a/activerecord/lib/active_record/autosave_association.rb
+++ b/activerecord/lib/active_record/autosave_association.rb
@@ -304,7 +304,8 @@ module ActiveRecord
def association_valid?(reflection, record)
return true if record.destroyed? || record.marked_for_destruction?
- unless valid = record.valid?
+ validation_context = self.validation_context unless [:create,:update].include?(self.validation_context)
+ unless valid = record.valid?(validation_context)
if reflection.options[:autosave]
record.errors.each do |attribute, message|
attribute = "#{reflection.name}.#{attribute}"