refactor has_many_keys to a module.