0

即使租户已存在,执行Apartment::Tenant.switch!("tenant_name")时出现错误。使用公寓宝石更换租户时出现错误

当我运行公寓:: tenant_names,它返回数组包含["murah5","rahmatullah","test"]然后我运行Apartment::Tenant.switch!("murah5")它返回:

Apartment::TenantNotFound: One of the following schema(s) is invalid: "murah5" "public" from /Users/fourtyonestudio/.rvm/gems/ruby-2.4.1/gems/apartment-1.2.0/lib/apartment/adapters/postgresql_adapter.rb:72:in救援connect_to_new'`

你可以帮我这个案子?

回答

0

你可以在该模型的方法(这将创建租户)

 class Tenant < ApplicationRecord 
     def self.switch(subdomain) 
     Apartment::Tenant.switch! subdomain 
     end 
    end 

那么你可以从轨控制台切换您的子像

Tenant.switch('app') 

通过Apartment::Tenant.current

检查你当前的子域名