diff options
author | Eric Chahin <erc73@cornell.edu> | 2014-05-01 02:38:15 -0400 |
---|---|---|
committer | Eric Chahin <erc73@cornell.edu> | 2014-05-01 03:27:24 -0400 |
commit | c6d685ba1118cc1f6303122117df945ebe8fceae (patch) | |
tree | b9d3b46fc5b454d8b8089411182da5cf936332c2 /activerecord/lib | |
parent | 876155705b56e66a8b9ed96f7b79d1c8d1763200 (diff) | |
download | rails-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.rb | 3 |
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}" |