{"record":{"id":"2ca8d9aeb74dabe9","repo":"mongodb/mongoid","slug":"attempted-to-persist-a-readonly-document-of-class-2ca8d9","errorCode":null,"errorMessage":"Attempted to persist a readonly document of class '%{klass}'.","messagePattern":"Attempted to persist a readonly document of class '%(.+?)'\\.","errorType":"exception","errorClass":"Mongoid::Errors::ReadonlyDocument","httpStatus":null,"severity":"error","filePath":"lib/mongoid/persistable/deletable.rb","lineNumber":108,"sourceCode":"      # @param [ Hash ] options The delete options.\n      #\n      # @return [ true | false ] If the parent should be notified.\n      def notifying_parent?(options = {})\n        !options.delete(:suppress)\n      end\n\n      # Prepare the delete operation.\n      #\n      # @api private\n      #\n      # @example Prepare the delete operation.\n      #   document.prepare_delete do\n      #     collection.find(atomic_selector).remove\n      #   end\n      #\n      # @return [ true ] If the object was deleted successfully.\n      def prepare_delete\n        raise Errors::ReadonlyDocument.new(self.class) if readonly?\n\n        yield(self)\n        freeze\n        self.destroyed = true\n      end\n\n      module ClassMethods\n        # Delete all documents given the supplied conditions. If no conditions\n        # are passed, the entire collection will be dropped for performance\n        # benefits. Does not fire any callbacks.\n        #\n        # @example Delete matching documents from the collection.\n        #   Person.delete_all({ :title => \"Sir\" })\n        #\n        # @example Delete all documents from the collection.\n        #   Person.delete_all\n        #\n        # @param [ Hash ] conditions Optional conditions to delete by.","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/persistable/deletable.rb#L90-L126","documentation":"Error \"Attempted to persist a readonly document of class '%{klass}'.\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/persistable/deletable.rb:108 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"}