aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-12-08 12:09:00 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-12-08 12:09:00 -0800
commitc69bd59a9cc7c0de3d6db7f8c90e73778516debf (patch)
treef8e03d1db22c8228a3a694e3b3f03ef9f35b709b
parentdcc0c9a8bb49d956476a7165f3eef6699ec4628b (diff)
downloadrails-c69bd59a9cc7c0de3d6db7f8c90e73778516debf.tar.gz
rails-c69bd59a9cc7c0de3d6db7f8c90e73778516debf.tar.bz2
rails-c69bd59a9cc7c0de3d6db7f8c90e73778516debf.zip
only call active_record once
-rw-r--r--activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
index bf0190e40a..09094f3ed5 100644
--- a/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
+++ b/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
@@ -80,10 +80,12 @@ module ActiveRecord
aliases = @join_dependency.table_aliases
if !aliases[name].zero? # We need an alias
- name = active_record.connection.table_alias_for "#{pluralize(reflection.name)}_#{parent_table_name}#{suffix}"
+ connection = active_record.connection
+
+ name = connection.table_alias_for "#{pluralize(reflection.name)}_#{parent_table_name}#{suffix}"
aliases[name] += 1
table_index = aliases[name]
- name = name[0..active_record.connection.table_alias_length-3] + "_#{table_index}" if table_index > 1
+ name = name[0, connection.table_alias_length-3] + "_#{table_index}" if table_index > 1
else
aliases[name] += 1
end