Вопрос

I my application I use apartment to have multi-tenancy and postgresql, so each tenant is in a different schema.
I have a User model in public (schema) and a model Action in each tenant (schema).
I want to have a relation has_and_belongs_to_many between those two models.
It works fine if I disable multi-tenancy.

I have read on the apartment's site that habtm doesn't work because there is no model to exclude, but it's not my case. I don't want to exclude it. The relation table is in the tenant schema, with the model Action. Only User is declare to be excluded (so User is in public).

I have an error message saying PG::InvalidSchemaName: ERROR: schma « actions_public » doesn't exist.

How can I do ?

Thanks for any help.

Это было полезно?

Решение

I answer my on question.

Because of the design of Apartment, it's not possible to use a habtm relation when a model is excluded on the other one is not.
The solution is to use a has_many :through relation.
Thanks.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top