You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
** (ArgumentError) cannot cast assoc `comment_likes`, assoc `comment_likes` not found. Make sure it is spelled correctly and properly pluralized (or singularized)
I think I can see why you can't cast_assoc a through association (though I think we could improve the error message!), but this trips me up when I try to automatically cast all associations with reflection.
Essentially if I do this: Post.__schema__(:associations) to find all of the associations that I need to cast, comment_likes is in the list.
The only way I can think to get this information right now is to use __changeset__ to figure out the list of associations, but that takes a lot more work.
Expected behavior
I'm not sure whether we could:
Add a reflection mechanism for through associations, so I can filter them out.
or
Exclude through associations from __schema__(:associations)
and / or
improve the error message.
The text was updated successfully, but these errors were encountered:
Use __schema__(:associations) and then check if the association is in __changeset__. That should fix your case. I will work on improving the error message. Thanks!
Precheck
Environment
Current behavior
Currently if you try to cast a through association you get the following (somewhat misleading) error message:
I think I can see why you can't
cast_assoc
a through association (though I think we could improve the error message!), but this trips me up when I try to automatically cast all associations with reflection.Essentially if I do this:
Post.__schema__(:associations)
to find all of the associations that I need to cast,comment_likes
is in the list.The only way I can think to get this information right now is to use
__changeset__
to figure out the list of associations, but that takes a lot more work.Expected behavior
I'm not sure whether we could:
through
associations, so I can filter them out.or
through
associations from__schema__(:associations)
and / or
The text was updated successfully, but these errors were encountered: