diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-01-31 01:20:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-31 01:20:21 -0500 |
commit | 505463c859927408665ce141426f098fea303a4e (patch) | |
tree | 831bf669ffd54ce5d9450bf4071152d14f2206f3 /activerecord/lib | |
parent | 44901ca9039dcf512a706b06c77e11004e661666 (diff) | |
parent | e09da8bf7853f8f4f1ebb5c52f9b688a32b4dfaa (diff) | |
download | rails-505463c859927408665ce141426f098fea303a4e.tar.gz rails-505463c859927408665ce141426f098fea303a4e.tar.bz2 rails-505463c859927408665ce141426f098fea303a4e.zip |
Merge pull request #27838 from kamipo/reload_destroyed_through_record
Reload `through_record` that has been destroyed in `create_through_record`
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/has_one_through_association.rb | 4 |
1 files changed, 4 insertions, 0 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 604904abcc..1183bdf6f4 100644 --- a/activerecord/lib/active_record/associations/has_one_through_association.rb +++ b/activerecord/lib/active_record/associations/has_one_through_association.rb @@ -22,6 +22,10 @@ module ActiveRecord elsif record attributes = construct_join_attributes(record) + if through_record && through_record.destroyed? + through_record = through_proxy.tap(&:reload).target + end + if through_record through_record.update(attributes) elsif owner.new_record? |