update multi_tenancy
This commit is contained in:
@@ -3,19 +3,19 @@ module MultiTenancy
|
|||||||
|
|
||||||
included do
|
included do
|
||||||
set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter
|
set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter
|
||||||
before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action
|
before_action :set_current_tenant_by_subdomain_or_frist if respond_to? :before_action
|
||||||
helper_method :current_shop if respond_to? :helper_method
|
helper_method :current_shop if respond_to? :helper_method
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_shop_by_subdomain_or_frist
|
def set_current_tenant_by_subdomain_or_frist
|
||||||
if request.subdomains.last
|
if request.subdomains.last && request.subdomains.last != 'www'
|
||||||
set_current_tenant(Shop.find_by(shop_code: request.subdomains.last.partition('-').last))
|
set_current_tenant(Shop.find_by(subdomain: request.subdomains.last))
|
||||||
end
|
end
|
||||||
current_shop
|
set_current_tenant(Shop.first) if current_tenant.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_shop
|
def current_shop
|
||||||
@shop ||= Shop.current_shop
|
ActsAsTenant.current_tenant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,6 +12,6 @@ class Shop < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.current_shop
|
def self.current_shop
|
||||||
RequestStore["current_shop"] ||= ActsAsTenant.current_tenant || Shop.first
|
ActsAsTenant.current_tenant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user