# CREATE TABLE as (id INT PRIMARY KEY, key TEXT);
# CREATE TABLE bs (id INT PRIMARY KEY, key TEXT);
class A < ActiveRecord::Base
has_many :bs, foreign_key: :key, primary_key: :key
end
class B < ActiveRecord::Base
end
B.create!(id: 1, key: "foo")
a = A.new(key: "foo")
puts(a.bs.count)
Without the gem, it prints 1, as it should. With the gem, it's 0. The problem is an apparent misprint in lib/composite_primary_keys/associations/has_many_association.rb:
Without the gem, it prints
1
, as it should. With the gem, it's0
. The problem is an apparent misprint inlib/composite_primary_keys/associations/has_many_association.rb
:It should be
Array(reflection.association_primary_key)
.