diff options
author | Matthew Draper <matthew@trebex.net> | 2014-05-03 16:19:24 +0930 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2014-05-03 16:29:40 +0930 |
commit | 022c797926591ed62d63f403ef314f2461b506ea (patch) | |
tree | 3e044af4274a7fc22f1e2950c5af198661dfc384 /activerecord/lib | |
parent | 193eb6252f0b2f0031acdb3157d4bb2efc0447c6 (diff) | |
parent | c6d685ba1118cc1f6303122117df945ebe8fceae (diff) | |
download | rails-022c797926591ed62d63f403ef314f2461b506ea.tar.gz rails-022c797926591ed62d63f403ef314f2461b506ea.tar.bz2 rails-022c797926591ed62d63f403ef314f2461b506ea.zip |
Merge pull request #14924 from eric-chahin/issue_13854
Fixed custom validation context bug for child associations
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..80cf7572df 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}" |