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
If you have a has_many association where the parent does not use hashids, find through the association doesn't return the associated record. I added a failing test case to demonstrate.
It seems that to solve this, apart from overriding .find on the model class, we would have to override ActiveRecord::Associations::CollectionProxy's #find method.
I have been trying to figure out how to extend the association automatically. Starting from the model with the hashid (Comment, in this case) you can get its belong-to associations via Comment.reflect_on_all_associations(:belongs_to), and get their inverses (if you have specified the inverse on the belongs_to associations) via .map(&:inverse_of), which are the has-many reflections (e.g. Post's has-many reflection for its comments association). But I don't know how to get from there to the association proxy (post.comments) in order to include/extend it with the behaviour we want.
If you have a has_many association where the parent does not use hashids, find through the association doesn't return the associated record. I added a failing test case to demonstrate.
It seems that to solve this, apart from overriding
.find
on the model class, we would have to overrideActiveRecord::Associations::CollectionProxy
's#find
method.Originally posted by @ahawrylak in #55 (comment)
The text was updated successfully, but these errors were encountered: