mongodb/mongoid · error · Mongoid::Errors::DocumentNotFound

Could not find a document of class %{klass}.

Error message

Could not find a document of class %{klass}.

What it means

Error "Could not find a document of class %{klass}." thrown in mongodb/mongoid.

Source

Thrown at lib/mongoid/contextual/memory.rb:784

      # Pluck the field values from the given document.
      #
      # @param [ Document ] doc The document to pluck from.
      # @param [ [ String | Symbol ]... ] *fields Field(s) to pluck.
      #
      # @return [ Object | Array<Object> ] The plucked values.
      def pluck_from_doc(doc, *fields)
        if fields.length == 1
          retrieve_value_at_path(doc, fields.first)
        else
          fields.map do |field|
            retrieve_value_at_path(doc, field)
          end
        end
      end

      def raise_document_not_found_error
        raise Errors::DocumentNotFound.new(klass, nil, nil)
      end
    end
  end
end

View on GitHub (pinned to 0da0e23d71)

When it happens

Trigger: Thrown at lib/mongoid/contextual/memory.rb:784 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of mongodb/mongoid@0da0e23d71 (2026-08-23). Data as JSON: /api/errors/06236591886c4db9. Report an issue: GitHub.