diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-14 21:35:52 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-14 21:35:52 -0300 |
commit | f85371f69d9fbc197c39b3c05b05d109952bde6e (patch) | |
tree | 9fcc2c3f98b00aaea9b222bb07cd24e24fbfe0ce /activerecord/lib/active_record/associations | |
parent | ec6bb3320991df57c00a30c61a03cb5b44942404 (diff) | |
parent | 8f6e5986acddf1c126bebf27774d7c7866bb4fa7 (diff) | |
download | rails-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.rb | 6 |
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 |