Fixes #7647: Added support for external registries

Why introduce an intermediate object that has no logic in it? That's precisely the point of has_and_belongs_to_many (as opposed to has_many through).