Create has_one relationship with flexible resource type
is there a "best practice" for creating a has_one relationship with a flexible resource type?
E.g. if I have the resources PrivateContact and PublicContact
Is something like the following possible?
relationships do
has_one :address, PrivateContact | PublicContact
end
1 Reply
There is really no great way to do polymorphism like that in Ash (or ecto)
Maybe it’s possible with ecto now I don’t want to speak for them.
But basically you end up creating a single resource with a
type
field
You could do it with a custom type and a calculation potentially.