-
Notifications
You must be signed in to change notification settings - Fork 21.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix replacing foreign key for a CPK association by id attribute
Given a model associated with a composite primary key by `id` attribute, for example: ```ruby Order.primary_key = [:shop_id, :id] OrderAgreement.primary_key = :id OrderAgreement.belongs_to :order, primary_key: :id ``` Assigning `order` to an `OrderAgreement` object will replace the `order_id` foreign key: ```ruby order = Order.last # => #<Order id: 1, shop_id: 2> order_agreement = OrderAgreement.new(order: order).save order_agreement.order_id # => 1 ```
- Loading branch information
1 parent
3d4dd9f
commit c0da60f
Showing
2 changed files
with
19 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters