class Bookyt::Elevator < Apartment::Elevators::Subdomain
  def parse_database_name(request)
    database_name = super
    if Apartment.database_names.include? database_name
      return database_name
    else
      return nil
    end
  end
end

class Bookyt::Elevator < Apartment::Elevators::Subdomain
  def parse_database_name(request)
    subdomain = super
    if tenant = Tenant.find_by_subdomain(subdomain)
      return tenant.db_name
    else
      return nil
    end
  end
end

Use db_name column to detect db for subdomain.
Use db_name column to detect db for subdomain.
