Fix *_ids method for has_many with primary_key

A `has_many` association with a custom `primary_key` was using the wrong primary key field name to find the list of associated IDs.

See https://github.com/rails/rails/issues/14439 for details.
Since this `if`/`else` block only uses methods from `source_reflection`, it seems like maybe this could be moved to whatever that class is?