Exception: Mongoid::Errors::DeleteRestriction

Inherits:
MongoidError
  • Object
show all
Defined in:
build/mongoid-7.3/lib/mongoid/errors/delete_restriction.rb

Overview

This error is raised when attempting to destroy a model which has an association with dependency option set to restrict.

Constant Summary

Constants inherited from MongoidError

MongoidError::BASE_KEY

Instance Attribute Summary

Attributes inherited from MongoidError

#problem, #resolution, #summary

Instance Method Summary collapse

Methods inherited from MongoidError

#compose_message

Constructor Details

#initialize(document, association_name) ⇒ DeleteRestriction

Create the new callbacks error.

Parameters:

  • document (Document)

    The document that was attempted to be destroyed.

  • association_name (Symbol)

    The name of the dependent association that prevents the document from being deleted.

Since:

  • 3.0.0



19
20
21
22
23
24
25
26
# File 'build/mongoid-7.3/lib/mongoid/errors/delete_restriction.rb', line 19

def initialize(document, association_name)
  super(
    compose_message(
      "delete_restriction",
      { document: document.class, relation: association_name }
    )
  )
end