Skip to content

Instantly share code, notes, and snippets.

@devkinoti
Created June 29, 2016 05:56
Show Gist options
  • Save devkinoti/5dcd2a77ec579dd38c4da7a36800e7cf to your computer and use it in GitHub Desktop.
Save devkinoti/5dcd2a77ec579dd38c4da7a36800e7cf to your computer and use it in GitHub Desktop.
tenant middleware to catch apartment tenant not found cases
class TenantMiddleware < Apartment::Elevators::Subdomain
def call(*args)
begin
super
rescue Apartment::TenantNotFound
Rails.logger.error "Error: Apartment Tenant Not found: #{Apartment::Tenant.current.inspect}"
return [404, {"Content-Type" => "application/json"},["Error => Tenant not found"]]
end
end
# def parse_tenant_name(request)
# request.env["HTTP_X_TENANT"]
# end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment