diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 62cc414555a90442ce3f0c406ae2bdb4631bcb41..2470eb44b4b56c772735be2ffa425d45612a17fe 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1307,7 +1307,7 @@ def collection_reader_method(reflection, association_proxy_class) if send(reflection.name).loaded? send(reflection.name).map(&:id) else - send(reflection.name).all(:select => "#{reflection.quoted_table_name}.id").map(&:id) + send(reflection.name).all(:select => "#{reflection.quoted_table_name}.#{reflection.klass.primary_key}").map(&:id) end end end