Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4650

Mongoid polymorphic associations with embeds

$
0
0

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?


Viewing all articles
Browse latest Browse all 4650

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>