aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/has_many_through_association.rb
diff options
context:
space:
mode:
authorVipul A M <vipulnsward@gmail.com>2016-01-24 22:03:00 +0530
committerVipul A M <vipulnsward@gmail.com>2016-01-24 22:25:12 +0530
commitb334bc93c6c3a37f69de9a130d43b8f1fda67e3c (patch)
tree5ac6d8d0e0adc6bd341298fb403f95c3e4ce1531 /activerecord/lib/active_record/associations/has_many_through_association.rb
parent83d2c39d5eb8d82ba124b6725d08c8e90760c764 (diff)
downloadrails-b334bc93c6c3a37f69de9a130d43b8f1fda67e3c.tar.gz
rails-b334bc93c6c3a37f69de9a130d43b8f1fda67e3c.tar.bz2
rails-b334bc93c6c3a37f69de9a130d43b8f1fda67e3c.zip
Add missing source_type if provided on hmt which belongs to an sti record
Fixes #23209
Diffstat (limited to 'activerecord/lib/active_record/associations/has_many_through_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb5
1 files changed, 5 insertions, 0 deletions
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