Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

associations is always a hash

  • Loading branch information...
commit c04a8192fdc78b5c24e33e16dab785e2b097009d 1 parent d0be8a0
@tenderlove tenderlove authored
Showing with 13 additions and 19 deletions.
  1. +13 −19 activerecord/lib/active_record/associations/join_dependency.rb
View
32 activerecord/lib/active_record/associations/join_dependency.rb
@@ -134,29 +134,23 @@ def join_base
end
def remove_duplicate_results!(base, records, associations)
- case associations
- when Symbol
- reflection = base.reflections[associations]
+ associations.each_key do |name|
+ reflection = base.reflections[name]
remove_uniq_by_reflection(reflection, records)
- when Hash
- associations.each_key do |name|
- reflection = base.reflections[name]
- remove_uniq_by_reflection(reflection, records)
-
- parent_records = []
- records.each do |record|
- if descendant = record.send(reflection.name)
- if reflection.collection?
- parent_records.concat descendant.target.uniq
- else
- parent_records << descendant
- end
+
+ parent_records = []
+ records.each do |record|
+ if descendant = record.send(reflection.name)
+ if reflection.collection?
+ parent_records.concat descendant.target.uniq
+ else
+ parent_records << descendant
end
end
+ end
- unless parent_records.empty?
- remove_duplicate_results!(reflection.klass, parent_records, associations[name])
- end
+ unless parent_records.empty?
+ remove_duplicate_results!(reflection.klass, parent_records, associations[name])
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.