【发布时间】:2020-08-17 19:03:59
【问题描述】:
我有一个 A 类
class A
include Mongoid::Document
has_many :bs
accepts_nested_attributes_for :bs
还有一个B类
class B
include Mongoid::Document
belongs_to :a
还有一个继承自 B 的 C 类
class C < B
field :new_field, type: String
这适用于 Mongoid 6。使用 Mongoid 7,在带有 fields_for 的表单上,提交后,我现在得到:
Attempted to set a value for 'new_field' which is not allowed on the model B
注意,这不是 7.0(我相信)b/c 中支持的 mongoid 多态性,它不是在谈论单表继承(STI),而是它支持属于单个类/表的多个表作为同一个符号.这不是那个。而且我尝试过使用 as 和 polymorphic:true。
任何想法如何解决这个问题?
谢谢, 凯文
【问题讨论】: