From 6183e55f714b436335dc843528be7525c342d922 Mon Sep 17 00:00:00 2001 From: miloops Date: Sat, 30 Aug 2008 21:13:53 -0300 Subject: [PATCH] Use reflection primary_key instead of id for when selecting association ids. [#906 state:resolved] Signed-off-by: Jeremy Kemper --- activerecord/lib/active_record/associations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 62cc414555..2470eb44b4 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 -- GitLab