aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-01-24 23:11:38 +0000
committerJon Leighton <j@jonathanleighton.com>2011-01-30 11:58:08 +0000
commit1da1ac159f9391b9a053a0fb0d426499b9edd5b7 (patch)
treea76994f7b43007f1a921f2381906c482d8eb7841
parent140b269fb7aee85e6da32da5305f771099d35af5 (diff)
downloadrails-1da1ac159f9391b9a053a0fb0d426499b9edd5b7.tar.gz
rails-1da1ac159f9391b9a053a0fb0d426499b9edd5b7.tar.bz2
rails-1da1ac159f9391b9a053a0fb0d426499b9edd5b7.zip
Just use primary_key here, AR::Relation will resolve the ambiguity before it is converted to SQL
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index 7fd15e4bd6..7504773639 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -146,7 +146,7 @@ module ActiveRecord
else
if @reflection.options[:uniq]
# This is needed because 'SELECT count(DISTINCT *)..' is not valid SQL.
- column_name = "#{@reflection.quoted_table_name}.#{@reflection.klass.primary_key}" unless column_name
+ column_name ||= @reflection.klass.primary_key
options.merge!(:distinct => true)
end