异常:Mongoid::Errors::AmbiguousRelationship

继承:
MongoidError
  • 对象
显示全部
定义于:
lib/mongoid/errors/ambiguous_relationship.rb

Overview

如果关联不明确,则会引发此错误。

例子:

不明确的关联。

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继承的属性

#问题#分辨率#summary

实例方法摘要折叠

MongoidError继承的方法

#compose_message

构造函数详情

#initialize (klass, inverse, name, Candidates) ⇒ AmbiguousRelationship

创建新的错误。

例子:

创建错误。

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

参数:

  • klass ( class )

    基类。

  • 反向 ( class )

    反向类。

  • 名称 (符号)

    关系名称。

  • 候选 ( Array<Symbol> )

    势倒数。



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

def 初始化(klass, 反向, 名称, 候选)
  (
    compose_message(
      " ambiguous_relationship ",
      {
        类: klass,
        反向: 反向,
        名称: 名称.检查,
        候选: 候选.map(:inspect).连接 (JOIN)(" , ")
      }
    )
  )
end