Fix has_and_belongs_to_many in a namespaced model pointing to a non namespaced model

Now the following case will work fine

    class Tag < ActiveRecord::Base
    end

    class Publisher::Article < ActiveRecord::Base
      has_and_belongs_to_many :tags
    end

Fixes #15761