aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-05-07 02:03:25 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-05-07 02:03:25 +0000
commitd59f3a78a423064f53dadd9f55d05b5f7b2b240e (patch)
tree2d69b9e85362f4b6b73422e5bb17e453a7af9208 /activerecord/lib/active_record/associations
parent50f538b72bbe6657627c9efe55b65d167956d1b7 (diff)
downloadrails-d59f3a78a423064f53dadd9f55d05b5f7b2b240e.tar.gz
rails-d59f3a78a423064f53dadd9f55d05b5f7b2b240e.tar.bz2
rails-d59f3a78a423064f53dadd9f55d05b5f7b2b240e.zip
uniq preserves order. References [4325].
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4326 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index e705576120..428152eea0 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -109,7 +109,14 @@ module ActiveRecord
end
def uniq(collection = self)
- collection.to_set.to_a
+ seen = Set.new
+ collection.inject([]) do |kept, record|
+ unless seen.include?(record.id)
+ kept << record
+ seen << record.id
+ end
+ kept
+ end
end
# Replace this collection with +other_array+