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

Metadata not found for document of type %{klass}.

Error message

Metadata not found for document of type %{klass}.

What it means

Error "Metadata not found for document of type %{klass}." thrown in mongodb/mongoid.

Source

Thrown at lib/mongoid/association.rb:104

    # @example Is the document in an embeds one?
    #   address.embedded_one?
    #
    # @return [ true | false ] True if in an embeds one.
    def embedded_one?
      _association && _association.is_a?(Association::Embedded::EmbedsOne)
    end

    # Get the association name for this document. If no association was defined
    #   an error will be raised.
    #
    # @example Get the association name.
    #   document.association_name
    #
    # @raise [ Errors::NoMetadata ] If no association metadata is present.
    #
    # @return [ Symbol ] The association name.
    def association_name
      raise Errors::NoMetadata.new(self.class.name) unless _association

      _association.name
    end

    # Determine if the document is part of an references_many association.
    #
    # @example Is the document in a references many?
    #   post.referenced_many?
    #
    # @return [ true | false ] True if in a references many.
    def referenced_many?
      _association && _association.is_a?(Association::Referenced::HasMany)
    end

    # Determine if the document is part of an references_one association.
    #
    # @example Is the document in a references one?
    #   address.referenced_one?

View on GitHub (pinned to 0da0e23d71)

When it happens

Trigger: Thrown at lib/mongoid/association.rb:104 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/37794aeb886c3a68. Report an issue: GitHub.