Closed msucorey closed 1 year ago
I have never used the polymorphic associations, didnt even know where in the code that it does that. After looking, I think its here https://github.com/miragejs/miragejs/blob/master/lib/orm/associations/belongs-to.js#L217 You can see there is a TODO to document it. But based on line 219 I think its newCommentable
even though the docs say buildCommentable
. I cant find in the code where build is preappended to anything.
Ah thanks, yeah saw that method - will attempt using that.
Ref https://miragejs.com/docs/main-concepts/relationships/, a model like 'comment' that has a polymorphic 'belongs to' commentable should have a createCommentable and buildCommentable method.
My models end up with only the create method (verified by inspecting the prototype). This almost serves the purpose, but if I try to instantiate the other model as an arg, I overflow the stack.
I need the build method so that I can use an existing instance of the model it will belong to and set the relationship up for testing.
Is this a bug? Or does it get fixed at some point past 1.1.8 - I couldn't tell from the docs. Also see https://github.com/miragejs/ember-cli-mirage/pull/1679.