aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-14 21:35:52 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-14 21:35:52 -0300
commitf85371f69d9fbc197c39b3c05b05d109952bde6e (patch)
tree9fcc2c3f98b00aaea9b222bb07cd24e24fbfe0ce /activerecord/lib/active_record/associations
parentec6bb3320991df57c00a30c61a03cb5b44942404 (diff)
parent8f6e5986acddf1c126bebf27774d7c7866bb4fa7 (diff)
downloadrails-f85371f69d9fbc197c39b3c05b05d109952bde6e.tar.gz
rails-f85371f69d9fbc197c39b3c05b05d109952bde6e.tar.bz2
rails-f85371f69d9fbc197c39b3c05b05d109952bde6e.zip
Merge pull request #14871 from kassio/kb-fixes-namespaced-habtm
Fix how to compute class name on habtm namespaced. Conflicts: activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/lib/active_record/associations')
-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