Exception: Mongoid::Errors::ReadonlyAssociation

Inherits:
MongoidError
  • Object
show all
Defined in:
lib/mongoid/errors/readonly_association.rb

Overview

Raised when attempting to write to a :through association, which is read-only.

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(klass, association) ⇒ ReadonlyAssociation

Instantiate the exception.

Examples:

Create the error.

ReadonlyAssociation.new(Physician, association)


15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mongoid/errors/readonly_association.rb', line 15

def initialize(klass, association)
  super(
    compose_message(
      'readonly_association',
      {
        klass: klass,
        name: association.name,
        through: association.options[:through]
      }
    )
  )
end