Ecto.Enum in Polymorphic Embed

I am trying to use Ecto.Enum in polymorphic embed. In case of normal schema, Ecto.Enum can be used as follows

@types [
    embed_comment: EmbedComment,
    serial_comment: SerialComment
  ]

  schema "posts" do

field :name, :string
field :type, Ecto.Enum, values: @types` 
timestamps()
  end

But in the below scenario, can I know what is the right syntax to use Ecto.Enum?

@types [
    embed_comment: EmbedComment,
    serial_comment: SerialComment
  ]

  schema "posts" do
    field :name, :string

    field :nodes, {:array, PolymorphicEmbed},
      types: ???

    timestamps()
  end

Any suggestions appreciated. Thank you

1 Like

Just noticed your question relating to polymorphic_embed. Simply using @types should work:

field :nodes, {:array, PolymorphicEmbed}, types: @types, on_replace: :delete
1 Like