diff options
author | Vipul A M <vipulnsward@gmail.com> | 2016-01-24 22:03:00 +0530 |
---|---|---|
committer | Vipul A M <vipulnsward@gmail.com> | 2016-01-24 22:25:12 +0530 |
commit | b334bc93c6c3a37f69de9a130d43b8f1fda67e3c (patch) | |
tree | 5ac6d8d0e0adc6bd341298fb403f95c3e4ce1531 /activerecord/lib/active_record/associations | |
parent | 83d2c39d5eb8d82ba124b6725d08c8e90760c764 (diff) | |
download | rails-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')
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_through_association.rb | 5 |
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 |