{"record":{"id":"46446ec0d57ea643","repo":"mongodb/mongoid","slug":"referencing-a-n-embedded-document-from-the-r","errorCode":null,"errorMessage":"Referencing a(n) %{embedded} document from the %{root} document via a non-embedded association is not allowed since the %{embedded} is embedded.","messagePattern":"Referencing a\\(n\\) %(.+?) document from the %(.+?) document via a non-embedded association is not allowed since the %(.+?) is embedded\\.","errorType":"exception","errorClass":"Mongoid::Errors::MixedRelations","httpStatus":null,"severity":"error","filePath":"lib/mongoid/association/proxy.rb","lineNumber":152,"sourceCode":"      # Whether the proxy can forward the method to the target.\n      #\n      # @param [ String | Symbol ] name The name of the method.\n      # @param [ Object... ] *args The +respond_to?+ arguments.\n      #\n      # @api private\n      ruby2_keywords def respond_to_missing?(name, *args)\n        _target.respond_to?(name, *args)\n      end\n\n      # When the base document illegally references an embedded document this\n      # error will get raised.\n      #\n      # @example Raise the error.\n      #   relation.raise_mixed\n      #\n      # @raise [ Errors::MixedRelations ] The error.\n      def raise_mixed\n        raise Errors::MixedRelations.new(_base.class, _association.klass)\n      end\n\n      # When the base is not yet saved and the user calls create or create!\n      # on the association, this error will get raised.\n      #\n      # @example Raise the error.\n      #   relation.raise_unsaved(post)\n      #\n      # @param [ Document ] doc The child document getting created.\n      #\n      # @raise [ Errors::UnsavedDocument ] The error.\n      def raise_unsaved(doc)\n        raise Errors::UnsavedDocument.new(_base, doc)\n      end\n\n      # Executes a callback method\n      #\n      # @example execute the before add callback","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/association/proxy.rb#L134-L170","documentation":"Error \"Referencing a(n) %{embedded} document from the %{root} document via a non-embedded association is not allowed since the %{embedded} is embedded.\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/association/proxy.rb:152 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"}