diff options
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/association_collection.rb | 9 |
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+ |