{"record":{"id":"103869e5d85d299f","repo":"mongodb/mongoid","slug":"accepting-nested-attributes-for-association-is","errorCode":null,"errorMessage":"Accepting nested attributes for %{association} is limited to %{limit} documents.","messagePattern":"Accepting nested attributes for %(.+?) is limited to %(.+?) documents\\.","errorType":"exception","errorClass":"Mongoid::Errors::TooManyNestedAttributeRecords","httpStatus":null,"severity":"error","filePath":"lib/mongoid/association/nested/many.rb","lineNumber":30,"sourceCode":"        # passed to the macro.\n        #\n        # This attempts to perform 3 operations, either one of an update of\n        # the existing association, a replacement of the association with a new\n        # document, or a removal of the association.\n        #\n        # It raises an argument error if the attributes are not a Hash or an\n        # Array of key/value pairs.\n        #\n        # @example Build the nested attrs.\n        #   many.build(person)\n        #\n        # @param [ Document ] parent The parent document of the association.\n        # @param [ Hash ] options The options.\n        #\n        # @return [ Array ] The attributes.\n        def build(parent, options = {})\n          @existing = parent.send(association.name)\n          raise Errors::TooManyNestedAttributeRecords.new(existing, options[:limit]) if over_limit?(attributes)\n\n          attributes.each do |attrs|\n            if attrs.is_a?(::Hash)\n              process_attributes(parent, attrs.with_indifferent_access)\n            elsif attrs.is_a?(Array) && attrs.length > 1 && attrs[1].respond_to?(:with_indifferent_access)\n              process_attributes(parent, attrs[1].with_indifferent_access)\n            elsif attrs.is_a?(Array) && attrs.length.even?\n              process_attributes(parent, Hash[*attrs].with_indifferent_access)\n            else\n              raise ArgumentError,\n                    \"Attributes for nested association '#{association.name}' must be a Hash or an Array of key/value pairs.\"\n            end\n          end\n        end\n\n        # Create the new builder for nested attributes on one-to-many\n        # associations.\n        #","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/association/nested/many.rb#L12-L48","documentation":"Error \"Accepting nested attributes for %{association} is limited to %{limit} documents.\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/association/nested/many.rb:30 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"}