aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-12-08 12:05:02 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-12-08 12:05:02 -0800
commitdcc0c9a8bb49d956476a7165f3eef6699ec4628b (patch)
tree3c9f47f7a18d88a8c43c491849bfe438f864847f /activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
parentde4bd472c3298f0455de8e3862c31900184f3c31 (diff)
downloadrails-dcc0c9a8bb49d956476a7165f3eef6699ec4628b.tar.gz
rails-dcc0c9a8bb49d956476a7165f3eef6699ec4628b.tar.bz2
rails-dcc0c9a8bb49d956476a7165f3eef6699ec4628b.zip
dry up calls to table_aliases
Diffstat (limited to 'activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb10
1 files changed, 6 insertions, 4 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 9c43e9edd7..bf0190e40a 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
@@ -77,13 +77,15 @@ module ActiveRecord
protected
def aliased_table_name_for(name, suffix = nil)
- if !@join_dependency.table_aliases[name].zero? # We need an alias
+ 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}"
- @join_dependency.table_aliases[name] += 1
- table_index = @join_dependency.table_aliases[name]
+ aliases[name] += 1
+ table_index = aliases[name]
name = name[0..active_record.connection.table_alias_length-3] + "_#{table_index}" if table_index > 1
else
- @join_dependency.table_aliases[name] += 1
+ aliases[name] += 1
end
name