Hi all,
I’m creating a resource that represents entities that can be either:
:naturalpersons or:legalpersons.
These have most attributes and actions in common and will primarily have to meet the need of having relationships along the lines of claim - belongs_to -> entity where the entity can be of either type. Of course, one would like to be able to query all entities and have their proper full name returned and so on.
I’m strongly suspecting that I should create a polymorphic relationship as described in the guides with an Entity resource and NaturalPerson and LegalPerson resources respectively, but a preliminary question has come to mind while evaluating the actual need for that.
If one were to have a resource Entity without that kind of polymorphism, could one have different :create actions that accept different attributes for the kinds of names that are then stored in :name1, :name2 and :name3 attributes on the Entity resource? Or would one “just” handle that in the UI?
:name1→:first_namefor:natural_person:s and:company_namefor:legal_person:s::name2→:middle_namefor:natural_person:s:name3→:last_namefor:natural_person:s
When for instance creating entities:s, I’d like to – somehow! – accept :first_name, :middle_name and :last_name in a :create_natural_person action and :company_name in a :create_legal_person action.
That does not feel very Ash:y however and I guess that it can lead to issues down the line.
As I noted above, I strongly suspect that this is a case of polymorphism.
Asking for a friend etc. ![]()
Thank you in advance good people!
Kind regards,
Carl
























