我正在构建多租户应用程序。
所有数据的隔离都是由每个表中的 TenantID 列完成的。
为所有租户模型自动处理多租户的最佳方法是什么。
例子:
Contacts.new({.....}) should automatically add :tenant => curret_user.tenant
Contacts.where({....}) should also add :tenant => curret_user.tenant
目前我在 CanCan gem 中看到了类似的东西,它可以获取特定用户参数的记录。但它没有为插入和更新操作提供任何东西。或者可能是我不明白该怎么做。
问候,阿列克谢·扎哈罗夫。