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

檢查你當前的子域名