diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-01-24 13:08:32 -0500 |
---|---|---|
committer | Rafael França <rafaelmfranca@gmail.com> | 2016-01-24 13:08:32 -0500 |
commit | 5119171d3927a99b73809aa29e58e8866ad07110 (patch) | |
tree | 148d57924108c741e0a7ff7b5852338b8e6ffcd9 /activerecord/lib/active_record/associations | |
parent | 6b89c4a24749ed972930ad1e27308bcda48c362b (diff) | |
parent | b334bc93c6c3a37f69de9a130d43b8f1fda67e3c (diff) | |
download | rails-5119171d3927a99b73809aa29e58e8866ad07110.tar.gz rails-5119171d3927a99b73809aa29e58e8866ad07110.tar.bz2 rails-5119171d3927a99b73809aa29e58e8866ad07110.zip |
Merge pull request #23221 from vipulnsward/23209-fix-missin_source_type
Add missing source_type if provided on hmt which belongs to an sti re…
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 |