aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/has_many_through_association.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-05-06 23:37:56 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-05-06 23:37:56 +0000
commit50f538b72bbe6657627c9efe55b65d167956d1b7 (patch)
treea3fd7a90a3d205ffd05f20ed4127c426e73cbbc4 /activerecord/lib/active_record/associations/has_many_through_association.rb
parente0123041750b724daa1e5fb4e7e66b233b2b1bed (diff)
downloadrails-50f538b72bbe6657627c9efe55b65d167956d1b7.tar.gz
rails-50f538b72bbe6657627c9efe55b65d167956d1b7.tar.bz2
rails-50f538b72bbe6657627c9efe55b65d167956d1b7.zip
Allow :uniq => true with has_many :through associations.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4325 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/associations/has_many_through_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb6
1 files changed, 4 insertions, 2 deletions
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