Exception: Mongoid::Errors::DeleteRestriction

Inherits:
MongoidError
  • Object
show all
Defined in:
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.



17
18
19
20
21
22
23
24
# File 'lib/mongoid/errors/delete_restriction.rb', line 17

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