提交 602fff1f 编写于 作者: J Jon Leighton

Merge pull request #1323 from fx/association_primary_key

use association_primary_key in AssociationScope#add_constraints
......@@ -60,7 +60,7 @@ def add_constraints(scope)
scope = scope.joins(join(
join_table,
table[reflection.active_record_primary_key].
table[reflection.association_primary_key].
eq(join_table[reflection.association_foreign_key])
))
......
......@@ -100,6 +100,16 @@ def test_should_property_quote_string_primary_keys
assert_equal 'c1', record[0]
assert_equal 't1', record[1]
end
def test_proper_usage_of_primary_keys_and_join_table
setup_data_for_habtm_case
assert_equal 'country_id', Country.primary_key
assert_equal 'treaty_id', Treaty.primary_key
country = Country.first
assert_equal 1, country.treaties.count
end
def test_has_and_belongs_to_many
david = Developer.find(1)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册