Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Multiple hasMany with as & through; TypeError: Cannot call method 'replace' #2316
I have two models that associate each other
Trying to associate a user as owner to a project like this works fine:
Trying to associate a user as user to a project fails:
with a stack trace
Only the association defined last in the models can be used. This can be tested by switching the ordering of the associations in the models. In my example, it's then possible to use
Please note that the above worked on 1.7.10 for me but now seems broken.
changed the title from
Multiple hasMany with as & through.
Multiple hasMany with as & through; TypeError: Cannot call method 'replace'
Sep 21, 2014
I have exactly the same problem.
I just upgraded from
And I after got this error
However I haved fixed it by defining plural
But after that I got this error:
What to do? It doesn't log enough error
@mickhansen No it is stack trace for
Here's the code (Its coffeescript)
And using the same above code for querying..
It's hitting the N:M code path, apparently it thinks one of your associations is N:M although it really shouldn't be.
Not sure, it's not a known bug and we have a ton of tests for relations like yours.
Can you try posting all your relations? Or was that all of them?
Well if they don't have any relations with the other tables it likely doesn't matter.
And you are absolutely sure that the error is from that find call?