aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/CHANGELOG4
-rwxr-xr-xactiverecord/lib/active_record/associations.rb2
2 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 9114f70ea1..ea920c7721 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -3,9 +3,9 @@
* Added smarter table aliasing for eager associations for multiple self joins #3580 [Rick Olson]
* The first time a table is referenced in a join, no alias is used.
- * After that, the parent table name and the reflection name are used.
+ * After that, the parent class name and the reflection name are used.
- Tree.find(:all, :include => :children) # LEFT OUTER JOIN trees AS tress_children ...
+ Tree.find(:all, :include => :children) # LEFT OUTER JOIN trees AS tree_children ...
* Any additional join references get a numerical suffix like '_2', '_3', etc.
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index d31d43c800..9e71c627c5 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1197,7 +1197,7 @@ module ActiveRecord
unless join_dependency.table_aliases[aliased_table_name].zero?
# if the table name has been used, then use an alias
# if the alias has been used, add a '_n' suffix to the end.
- @aliased_table_name = "#{parent.table_name}_#{reflection.name}_#{join_dependency.table_aliases[aliased_table_name]}".gsub(/_1$/, '')
+ @aliased_table_name = "#{parent.active_record.to_s.underscore}_#{reflection.name}_#{join_dependency.table_aliases[aliased_table_name]}".gsub(/_1$/, '')
end
join_dependency.table_aliases[aliased_table_name] += 1
end