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.

Revisions

  1. devkinoti created this gist Jun 29, 2016.
    14 changes: 14 additions & 0 deletions rescued_apartment_middleware.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    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