21 lines
559 B
Ruby
21 lines
559 B
Ruby
module MultiTenancy
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
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
|
|
end
|
|
|
|
private
|
|
def find_shop_by_subdomain_or_frist
|
|
if request.subdomain.present?
|
|
shop_code = request.subdomain.partition('-').last
|
|
@shop = Shop.find_by(shop_code: shop_code)
|
|
else
|
|
# @shop = Shop.first
|
|
@shop = Shop.find_by(shop_code: '262')
|
|
end
|
|
set_current_tenant(@shop)
|
|
end
|
|
end
|