{"record":{"id":"99dbe17196120eb9","repo":"mongodb/mongoid","slug":"defining-an-association-named-name-is-not-all","errorCode":null,"errorMessage":"Defining an association named '%{name}' is not allowed.","messagePattern":"Defining an association named '%(.+?)' is not allowed\\.","errorType":"exception","errorClass":"Mongoid::Errors::InvalidRelation","httpStatus":null,"severity":"error","filePath":"lib/mongoid/association/relatable.rb","lineNumber":440,"sourceCode":"          end\n        end\n\n        if @options.key?(:fallback)\n          unless @options[:fallback].respond_to?(:call)\n            raise ArgumentError,\n                  \"The :fallback option for association '#{name}' on \" \\\n                  \"#{@owner_class} must be a Proc or lambda.\"\n          end\n\n          if @options.key?(:autobuild)\n            raise ArgumentError,\n                  \"The :fallback option for association '#{name}' on \" \\\n                  \"#{@owner_class} cannot be combined with :autobuild.\"\n          end\n        end\n\n        [ name, :\"#{name}?\", :\"#{name}=\" ].each do |n|\n          raise Errors::InvalidRelation.new(@owner_class, n) if Mongoid.destructive_fields.include?(n)\n        end\n      end\n\n      def polymorph!\n        return unless polymorphic?\n\n        @owner_class.polymorphic = true\n      end\n\n      def create_extension!(&block)\n        return unless block\n\n        extension_module_name = \"#{@owner_class.to_s.demodulize}#{name.to_s.camelize}RelationExtension\"\n        silence_warnings do\n          @owner_class.const_set(extension_module_name, Module.new(&block))\n        end\n        @extension = \"#{@owner_class}::#{extension_module_name}\".constantize\n      end","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/association/relatable.rb#L422-L458","documentation":"Error \"Defining an association named '%{name}' is not allowed.\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/association/relatable.rb:440 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"}