Please sign in to comment.
Allow assignment on has_one :through where the owner is a new record [#…
…5137 state:resolved] This required changing the code to keep the association proxy for a belongs_to around, despite its target being nil. Which in turn required various changes to the way that stale target checking is handled, in order to support various edge cases (loaded target is nil then foreign key added, foreign key is changed and then changed back, etc). A side effect is that the code is nicer and more succinct. Note that I am removing test_no_unexpected_aliasing since that is basically checking that the proxy for a belongs_to *does* change, which is the exact opposite of the intention of this commit. Also adding various tests for various edge cases and related things. Phew, long commit message!
- Loading branch information...
Showing with 113 additions and 85 deletions.
- +12 −11 activerecord/lib/active_record/associations.rb
- +22 −9 activerecord/lib/active_record/associations/association_proxy.rb
- +4 −11 activerecord/lib/active_record/associations/belongs_to_association.rb
- +4 −13 activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
- +0 −1 activerecord/lib/active_record/associations/has_many_through_association.rb
- +1 −3 activerecord/lib/active_record/associations/has_one_association.rb
- +1 −1 activerecord/lib/active_record/associations/has_one_through_association.rb
- +7 −13 activerecord/lib/active_record/associations/through_association.rb
- +1 −0 activerecord/lib/active_record/autosave_association.rb
- +14 −19 activerecord/test/cases/associations/belongs_to_associations_test.rb
- +17 −3 activerecord/test/cases/associations/eager_test.rb
- +22 −0 activerecord/test/cases/associations/has_one_through_associations_test.rb
- +7 −0 activerecord/test/cases/autosave_association_test.rb
- +0 −1 activerecord/test/cases/nested_attributes_test.rb
- +1 −0 activerecord/test/models/company.rb