From 50f538b72bbe6657627c9efe55b65d167956d1b7 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 6 May 2006 23:37:56 +0000 Subject: Allow :uniq => true with has_many :through associations. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4325 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/active_record/associations/has_many_through_association.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/associations/has_many_through_association.rb') diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb index 8cafb26d44..037c375cde 100644 --- a/activerecord/lib/active_record/associations/has_many_through_association.rb +++ b/activerecord/lib/active_record/associations/has_many_through_association.rb @@ -56,9 +56,9 @@ module ActiveRecord @reflection.klass.with_scope(construct_scope) { @reflection.klass.send(method, *args, &block) } end end - + def find_target - @reflection.klass.find(:all, + records = @reflection.klass.find(:all, :select => construct_select, :conditions => construct_conditions, :from => construct_from, @@ -68,6 +68,8 @@ module ActiveRecord :group => @reflection.options[:group], :include => @reflection.options[:include] || @reflection.source_reflection.options[:include] ) + + @reflection.options[:uniq] ? records.to_set.to_a : records end def construct_conditions -- cgit v1.2.3