如何破坏另一个模式中的关联?
How destroy associations in another schema?
我正在使用 apartment gem 并且我的用户(public 架构)有很多争议(组织架构),当删除有争议的用户时,相关的争议仍保留在数据库中。
我的用户模型有正确的关联:
has_many :disputes, dependent: :destroy
有什么特别的设置需要我做吗?谢谢
解决方案很简单,您应该始终通过租户 url 调用您的请求,切勿使用 public(模式)url。
例子
租户URL
DELETE http://bank.api.lvh.me:3000/users/1 # Bank is the name of tenant.
Public(模式)URL
DELETE http://api.lvh.me:3000/users/1 # Only delete the user, not with associations.
我正在使用 apartment gem 并且我的用户(public 架构)有很多争议(组织架构),当删除有争议的用户时,相关的争议仍保留在数据库中。
我的用户模型有正确的关联:
has_many :disputes, dependent: :destroy
有什么特别的设置需要我做吗?谢谢
解决方案很简单,您应该始终通过租户 url 调用您的请求,切勿使用 public(模式)url。
例子
租户URL
DELETE http://bank.api.lvh.me:3000/users/1 # Bank is the name of tenant.
Public(模式)URL
DELETE http://api.lvh.me:3000/users/1 # Only delete the user, not with associations.