Closed OscarGodson closed 9 years ago
Could you add the code that produced the error? Were you trying to save an item with a newly added association? We do have some good examples of through-associations in our tests:
https://github.com/geddy/model/tree/master/test/fixtures https://github.com/geddy/model/blob/master/test/integration/adapters/shared.js
Events and People are many-to-many through Participations, for example.
The line of code that errors out is just:
userModel.addFamily(FamilyModel.create({name: 'Your Family'}));
But, to be clear, the create above is not the thing that errors. It has to be something internal because typeof FamilyModel.create
returns [Function]
. So it's some internal Geddy create thing that is undefined.
I'll take a look at those fixtures.
It can't find the model definition (constructor) for the join model (in your case FamiliesUser
). It has to create an instance of that to store the link between the user and the family.
Let me know what if anything you can find out.
I responded with a small PR to hopefully help others :)
Once you merge the PR, can you close this?
Below is the code I'm trying to run (minus some obvious code, like
require()
s). It worked until I added the through associations. I have a table namedfamilies_users
also.User Model
Family Model
FamiliesUser Model
I changed
FamiliesUser
/families_users
references and tables toMember
/members
and now I'm getting a"No inverse found for this through-association."
which is a different error and I can figure that one out but means it must be something with the pluralization or two worded model maybe? Any ideas?