Polymorphic Self References
Can't seem to figure out how to accomplish the following. I have a polymorphic table that is meant to model a tree relationship. this of course requires a belongs_to and has_many relationship to itself.
How do I go about defining a self referential relationship that is mean to pickup on context provided by the consumer? Such that all the relationships are within the same table?
3 Replies
My guess is that this is where I want to reach for manual relationships?
No I guess that doesn't work since the foreign key constraint will never be set.
I guess I might not be able to use polymorphic resources for this.
Yeah, I haven’t considered this use case TBH.
We could maybe work something up but I don’t think it's supported currently.
You might need to define each resource manually.
I think all I really want to do is to pass on what the consumer specifies in the data_layer context
but I guess I can write a macro module to generate the resources for me. In the meantime I'll probably write up a feature request on the github.