diff --git a/app/middleware/account_elevator.rb b/app/middleware/account_elevator.rb index 1bdf38e85..6160b9a6e 100644 --- a/app/middleware/account_elevator.rb +++ b/app/middleware/account_elevator.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require 'apartment/elevators/generic' # Apartment middleware for switching tenants based on the # CNAME entry for an account. class AccountElevator < Apartment::Elevators::Generic @@ -7,7 +8,7 @@ class AccountElevator < Apartment::Elevators::Generic # @return [String] The tenant to switch to def parse_tenant_name(request) account = Account.from_request(request) - + account || Account.new.reset! # reset everything if no account is present account&.tenant end end