异常:Mongoid::Errors::InvalidSetPolymorphicRelation

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

Overview

尝试设置与模型的多态“引用”关联,其中多个“引用多/一个”关联指向第一个模型时,则引发此警报。

例子:

多态关联设置无效。

class Face
  include Mongoid::Document

  has_one :left_eye, class_name: "Eye", as: :eyeable
  has_one :right_eye, class_name: "Eye", as: :eyeable
end

class Eye
  include Mongoid::Document

  belongs_to :eyeable, polymorphic: true
end

eye = Eye.new
face = Face.new
eye.eyeable = face # Raises error

常量摘要

MongoidError继承的常量

MongoidError::BASE_KEY

实例属性摘要

MongoidError继承的属性

#问题#分辨率#summary

实例方法摘要折叠

MongoidError继承的方法

#compose_message

构造函数详情

#initialize (name, klass, other_klass) ⇒ InvalidSetPolymorphicRelation

创建新的无效设立多态关联错误。

例子:

创建错误。

InvalidSetPolymorphicRelation.new


34
35
36
# File 'lib/mongoid/errors/invalid_set_polymorphic_relation.rb', line 34

def 初始化(名称, klass, other_klass)
  (compose_message(" invalid_set_polymorphic_relation ", { 名称: 名称, 类: klass, other_klass: other_klass }))
end