Skip to content

Instantly share code, notes, and snippets.

@BenMorganIO
Created March 31, 2017 23:22
Show Gist options
  • Save BenMorganIO/d541d086dd8043d7d26c8db05e585a23 to your computer and use it in GitHub Desktop.
Save BenMorganIO/d541d086dd8043d7d26c8db05e585a23 to your computer and use it in GitHub Desktop.
defmodule Ryal.PaymentMethod do
schema "ryal_payment_methods" do
field :type, :string
embeds_one :data, modularize_field(:type) # :p
end
end
# or, can I do:
schema "ryal_payment_methods" do
field :type, :string
embeds_one :data, Ryal.PaymentMethod.CreditCard
embeds_one :data, Ryal.PaymentMethod.Bitcoin
end
@duanearnett
Copy link

Did you ever find a decent way to do this? Found this gist through the IRC logs and am trying to figure out how to do the same thing (https://botbot.me/freenode/elixir-lang/2017-03-31/?msg=40248917&page=7)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment