From b334bc93c6c3a37f69de9a130d43b8f1fda67e3c Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Sun, 24 Jan 2016 22:03:00 +0530 Subject: Add missing source_type if provided on hmt which belongs to an sti record Fixes #23209 --- .../lib/active_record/associations/has_many_through_association.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb index deb0f8c9f5..36fc381343 100644 --- a/activerecord/lib/active_record/associations/has_many_through_association.rb +++ b/activerecord/lib/active_record/associations/has_many_through_association.rb @@ -66,6 +66,11 @@ module ActiveRecord through_record = through_association.build(*options_for_through_record) through_record.send("#{source_reflection.name}=", record) + + if options[:source_type] + through_record.send("#{source_reflection.foreign_type}=", options[:source_type]) + end + through_record end end -- cgit v1.2.3