aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorKassio Borges <kassioborgesm@gmail.com>2014-05-13 11:25:21 -0300
committerKassio Borges <kassioborgesm@gmail.com>2014-05-13 11:26:46 -0300
commit8f6e5986acddf1c126bebf27774d7c7866bb4fa7 (patch)
tree759a0bddecfba7e35e7feb2a5fdca4acc21362dc /activerecord/lib/active_record
parentc6c164238305b1aaebff54758035f676feeeb06e (diff)
downloadrails-8f6e5986acddf1c126bebf27774d7c7866bb4fa7.tar.gz
rails-8f6e5986acddf1c126bebf27774d7c7866bb4fa7.tar.bz2
rails-8f6e5986acddf1c126bebf27774d7c7866bb4fa7.zip
Fix how to compute class name on habtm namespaced.
Thank's for @laurocaetano for the help with tests. :smiley: Fixes #14709
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb6
1 files changed, 5 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 e472277374..ad781e50c9 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
@@ -23,7 +23,11 @@ module ActiveRecord::Associations::Builder
KnownTable.new options[:join_table].to_s
else
class_name = options.fetch(:class_name) {
- name.to_s.camelize.singularize
+ model_name = name.to_s.camelize.singularize
+ if parent_name = lhs_class.parent_name.presence
+ model_name = model_name.prepend("#{parent_name}::")
+ end
+ model_name
}
KnownClass.new lhs_class, class_name
end