diff options
author | Emilio Tagua <miloops@gmail.com> | 2010-09-22 11:22:49 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2010-09-22 18:08:02 -0300 |
commit | f6de806537d60e94183f26cd6a16da426e84911e (patch) | |
tree | 2503283268739135d102222a59876a0d74526eb9 | |
parent | 2da809da37c51801f1f97ef4e83b1db13753898d (diff) | |
download | rails-f6de806537d60e94183f26cd6a16da426e84911e.tar.gz rails-f6de806537d60e94183f26cd6a16da426e84911e.tar.bz2 rails-f6de806537d60e94183f26cd6a16da426e84911e.zip |
Refactor association_collection uniq method.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
-rw-r--r-- | activerecord/lib/active_record/associations/association_collection.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index 1221a56bbc..91e0a9f2f8 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -338,13 +338,12 @@ module ActiveRecord def uniq(collection = self) seen = Set.new - collection.inject([]) do |kept, record| + collection.map do |record| unless seen.include?(record.id) - kept << record seen << record.id + record end - kept - end + end.compact end # Replace this collection with +other_array+ |