aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-04-22 04:03:36 +0900
committerGitHub <noreply@github.com>2018-04-22 04:03:36 +0900
commitaa941c9ce19924589e508f6a1e4bc2d8361a89ae (patch)
tree0bc4f8accb22b0f8fe9538b1e2089be442106676 /activerecord/lib/active_record
parent611e1102d3bd46c4765bec7d57ca8d343c419e33 (diff)
parent99910dddf28faac31d6a3d4800460f1bc308bb83 (diff)
downloadrails-aa941c9ce19924589e508f6a1e4bc2d8361a89ae.tar.gz
rails-aa941c9ce19924589e508f6a1e4bc2d8361a89ae.tar.bz2
rails-aa941c9ce19924589e508f6a1e4bc2d8361a89ae.zip
Merge pull request #32514 from samdec/multiple-has-one-through-associations-build-bug
Fix .new with multiple through associations
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations/has_one_through_association.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/has_one_through_association.rb b/activerecord/lib/active_record/associations/has_one_through_association.rb
index 491282adf7..019bf0729f 100644
--- a/activerecord/lib/active_record/associations/has_one_through_association.rb
+++ b/activerecord/lib/active_record/associations/has_one_through_association.rb
@@ -28,7 +28,11 @@ module ActiveRecord
end
if through_record
- through_record.update(attributes)
+ if through_record.new_record?
+ through_record.assign_attributes(attributes)
+ else
+ through_record.update(attributes)
+ end
elsif owner.new_record? || !save
through_proxy.build(attributes)
else