예외: Mongoid::Errors::AmbiguousRelationship

상속:
MongoidError
  • 객체
모두 표시
다음에 정의됨:
lib/mongoid/errors/ambiguous_relationship.rb

개요

이 오류는 모호한 연관 관계의 경우에 발생합니다.

예시:

모호한 연관 관계입니다.

class Person
  include Mongoid::Document

  has_many :invitations, inverse_of: :person
  has_many :referred_invitations, class_name: "Invitation", inverse_of: :referred_by
end

class Invitation
  include Mongoid::Document

  belongs_to :person
  belongs_to :referred_by, class_name: "Person"
end

상수 요약

MongoidError에서 상속된 상수

MongoidError::BASE_KEY

인스턴스 속성 요약

MongoidError에서 상속된 속성

#problem, #Resolution, #summary

인스턴스 메서드 요약 접기

MongoidError에서 상속된 메서드

#compose_message

생성자 세부 정보

#initialize(klass, inverse, name, 후보) ⇒ AmbiguousRelationship

새 오류를 만듭니다.

예시:

오류를 생성합니다.

AmbiguousRelationship.new(
  Person, Drug, :person, [ :drugs, :evil_drugs ]
)

매개변수:

  • class (클래스)

    기본 클래스.

  • inverse (클래스)

    역 클래스.

  • 이름 (기호)

    관계 이름입니다.

  • 후보자 (Array<Symbol>)

    잠재적 반전.



36
37
38
39
40
41
42
43
44
45
46
47
48
# 파일 'lib/mongoid/errors/ambiguous_relationship.rb', 줄 36

def 초기화(class, inverse, 이름, 후보자)
  super(
    Compose_message(
      "ambiguous_relationship",
      {
        class: class,
        inverse: inverse,
        이름: 이름.검사,
        후보: 후보자.map(&:inspect).가입(", ")
      }
    )
  )
end