Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obj_extract should treat ActiveRecord::Associations::CollectionProxy as an Array #119

Open
jrochkind opened this issue Apr 13, 2021 · 0 comments

Comments

@jrochkind
Copy link
Contributor

Right now it doesn't, so you need to explicitly put to_a into your obj_extract paths, to turn it into an array.

One way to accomplish this would be to treat anything that respond_to?(:to_ary) as an array, rather than hard-coding ActiveRecord::Associations::CollectionProxy. Note that's to_ary not to_a, and thus should work fine, only things that really are meant to be interchangeable with Array should have to_ary.

I think this is a definite improvement... but ti's a backward incompatibility, since anything doing an explicit to_a will break.

Could be done with an obj_extract2 or something to be backwards compat. I dunno.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant