Fix how to compute class name on habtm namespaced.

Fixes #14709