{"record":{"id":"e19d1bf3f04e3546","repo":"mongodb/mongoid","slug":"the-name-attribute-can-t-be-set-to-an-instance-e19d1b","errorCode":null,"errorMessage":"The %{name} attribute can't be set to an instance of %{other_klass} as %{other_klass} has multiple associations referencing %{klass} as %{name}.","messagePattern":"The %(.+?) attribute can't be set to an instance of %(.+?) as %(.+?) has multiple associations referencing %(.+?) as %(.+?)\\.","errorType":"exception","errorClass":"Mongoid::Errors::InvalidSetPolymorphicRelation","httpStatus":null,"severity":"error","filePath":"lib/mongoid/association/referenced/belongs_to/binding.rb","lineNumber":78,"sourceCode":"              end\n            end\n          end\n\n          private\n\n          # Check for problems with multiple inverse definitions.\n          #\n          # @api private\n          #\n          # @example Check for inverses errors.\n          #   binding.check_inverses!(doc)\n          #\n          # @param [ Document ] doc The document to check.\n          def check_polymorphic_inverses!(doc)\n            inverses = _association.inverses(doc)\n            return unless inverses.length > 1 && _base.send(_association.foreign_key).nil?\n\n            raise Errors::InvalidSetPolymorphicRelation.new(\n              _association.name, _base.class.name, _target.class.name\n            )\n          end\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":60,"sourceCodeEnd":87,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/association/referenced/belongs_to/binding.rb#L60-L87","documentation":"Error \"The %{name} attribute can't be set to an instance of %{other_klass} as %{other_klass} has multiple associations referencing %{klass} as %{name}.\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/association/referenced/belongs_to/binding.rb:78 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"}