mirror of https://github.com/rails/rails
Merge pull request #48400 from adrianna-chang-shopify/ac-scope-for-create-on-cpk
Fix `#scope_for_create` for belongs_to associations with CPK
This commit is contained in:
commit
e7be1e76bc
|
@ -34,7 +34,7 @@ module ActiveRecord
|
|||
|
||||
private
|
||||
def scope_for_create
|
||||
super.except!(klass.primary_key)
|
||||
super.except!(*Array(klass.primary_key))
|
||||
end
|
||||
|
||||
def find_target
|
||||
|
|
|
@ -35,7 +35,7 @@ require "models/cpk"
|
|||
class BelongsToAssociationsTest < ActiveRecord::TestCase
|
||||
fixtures :accounts, :companies, :developers, :projects, :topics,
|
||||
:developers_projects, :computers, :authors, :author_addresses,
|
||||
:essays, :posts, :tags, :taggings, :comments, :sponsors, :members, :nodes
|
||||
:essays, :posts, :tags, :taggings, :comments, :sponsors, :members, :nodes, :cpk_books
|
||||
|
||||
def test_belongs_to
|
||||
client = Client.find(3)
|
||||
|
@ -356,6 +356,15 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
|
|||
assert_equal apple.id, citibank.firm_id
|
||||
end
|
||||
|
||||
def test_building_the_belonging_object_for_composite_primary_key
|
||||
cpk_book = cpk_books(:cpk_great_author_first_book)
|
||||
order = cpk_book.build_order
|
||||
cpk_book.save
|
||||
|
||||
_shop_id, id = order.id
|
||||
assert_equal id, cpk_book.order_id
|
||||
end
|
||||
|
||||
def test_building_the_belonging_object_with_implicit_sti_base_class
|
||||
account = Account.new
|
||||
company = account.build_firm
|
||||
|
|
Loading…
Reference in New Issue