{"record":{"id":"37794aeb886c3a68","repo":"mongodb/mongoid","slug":"metadata-not-found-for-document-of-type-klass","errorCode":null,"errorMessage":"Metadata not found for document of type %{klass}.","messagePattern":"Metadata not found for document of type %(.+?)\\.","errorType":"exception","errorClass":"Mongoid::Errors::NoMetadata","httpStatus":null,"severity":"error","filePath":"lib/mongoid/association.rb","lineNumber":104,"sourceCode":"    # @example Is the document in an embeds one?\n    #   address.embedded_one?\n    #\n    # @return [ true | false ] True if in an embeds one.\n    def embedded_one?\n      _association && _association.is_a?(Association::Embedded::EmbedsOne)\n    end\n\n    # Get the association name for this document. If no association was defined\n    #   an error will be raised.\n    #\n    # @example Get the association name.\n    #   document.association_name\n    #\n    # @raise [ Errors::NoMetadata ] If no association metadata is present.\n    #\n    # @return [ Symbol ] The association name.\n    def association_name\n      raise Errors::NoMetadata.new(self.class.name) unless _association\n\n      _association.name\n    end\n\n    # Determine if the document is part of an references_many association.\n    #\n    # @example Is the document in a references many?\n    #   post.referenced_many?\n    #\n    # @return [ true | false ] True if in a references many.\n    def referenced_many?\n      _association && _association.is_a?(Association::Referenced::HasMany)\n    end\n\n    # Determine if the document is part of an references_one association.\n    #\n    # @example Is the document in a references one?\n    #   address.referenced_one?","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/association.rb#L86-L122","documentation":"Error \"Metadata not found for document of type %{klass}.\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/association.rb:104 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}