aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorTakayuki Nakata <f.seasons017@gmail.com>2019-07-26 23:12:44 +0900
committerTakayuki Nakata <f.seasons017@gmail.com>2019-07-26 23:12:44 +0900
commit285f081e1ddf0a552ae1331a76cdaa90a51f319c (patch)
tree640b26869d72d2e2431db073fa1ffca1d0cba1fd /activerecord/lib
parent3ecaf0aafa43ff6fd511c6557592591ee5731244 (diff)
downloadrails-285f081e1ddf0a552ae1331a76cdaa90a51f319c.tar.gz
rails-285f081e1ddf0a552ae1331a76cdaa90a51f319c.tar.bz2
rails-285f081e1ddf0a552ae1331a76cdaa90a51f319c.zip
Fix join middle table alias when using HABTM
In using HABTM, join middle table alias is combined with the associated models name without sort, while middle table name is combined with those models name with sort. Fixes #36742.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb b/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb
index 6ad4c75fb5..2072f93194 100644
--- a/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb
+++ b/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb
@@ -62,7 +62,7 @@ module ActiveRecord::Associations::Builder # :nodoc:
def middle_reflection(join_model)
middle_name = [lhs_model.name.downcase.pluralize,
- association_name].join("_").gsub("::", "_").to_sym
+ association_name.to_s].sort.join("_").gsub("::", "_").to_sym
middle_options = middle_options join_model
HasMany.create_reflection(lhs_model,