From ad47b7bcc11aae7745b39354292b089ae18a8cfc Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 10 Dec 2010 17:03:32 -0800 Subject: just use the regexp directly --- .../associations/class_methods/join_dependency.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/associations/class_methods/join_dependency.rb b/activerecord/lib/active_record/associations/class_methods/join_dependency.rb index 6be947df41..5a0ff942ca 100644 --- a/activerecord/lib/active_record/associations/class_methods/join_dependency.rb +++ b/activerecord/lib/active_record/associations/class_methods/join_dependency.rb @@ -58,18 +58,16 @@ module ActiveRecord when Arel::Table right.name.downcase == name ? 1 : 0 when String - count_aliases_from_string(right.downcase, quoted_name) + # Table names + table aliases + right.downcase.scan( + /join(?:\s+\w+)?\s+(\S+\s+)?#{quoted_name}\son/ + ).size else 0 end }.sum end - def count_aliases_from_string(join_sql, name) - # Table names + table aliases - join_sql.scan(/join(?:\s+\w+)?\s+(\S+\s+)?#{name}\son/).size - end - def instantiate(rows) primary_key = join_base.aliased_primary_key parents = {} -- cgit v1.2.3