From fba18f19948f084023fd8744025f57da00163265 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Fri, 10 May 2013 17:41:29 +0200 Subject: Extract JoinDependency#join_relation to DRY the repeated application of the #join_associations. --- activerecord/lib/active_record/associations/join_dependency.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activerecord/lib/active_record/associations') diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 28e081c03c..5b2f2d1902 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -55,6 +55,13 @@ module ActiveRecord join_parts.first end + def join_relation(relation) + join_associations.each do |association| + relation = association.join_relation(relation) + end + relation + end + def columns join_parts.collect { |join_part| table = join_part.aliased_table -- cgit v1.2.3