I'm confused on how to make polymorphism work with embeds and mongoid 8.x.
class Entity include Mongoid::Document embeds_many :custom_fields, as: :itemendclass EmailField include Mongoid::Document field :name, type: String field :value, type: String embedded_in :item, polymorphic: trueendclass MultivalueField include Mongoid::Document field :name field :value, type: Array embedded_in :item, polymorphic: trueend
I don't understand why this doesn't work. What I expect is the model Entity
to have many fields of different types embedded, but it explodes with
NameError: uninitialized constant MetadataService::Models::Entity::CustomField
What am I doing wrong?