class ActiveRecord::Reflection::ThroughReflection

def association_primary_key(klass = nil)

need to respect the source_reflection's :primary_key option, though.
the source_reflection, because the source_reflection may be polymorphic. We still
We want to use the klass from this reflection, rather than just delegate straight to
def association_primary_key(klass = nil)
  # Get the "actual" source reflection if the immediate source reflection has a
  # source reflection itself
  if primary_key = actual_source_reflection.options[:primary_key]
    @association_primary_key ||= -primary_key.to_s
  else
    primary_key(klass || self.klass)
  end
end