Fix unintentionally calling to_a
on the target
#502
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The fix in #448 had some unintented consequences. We have a custom
to_a
method on one of our ActiveRecord objects which returns a set of different ActiveRecord objects. (Yes, I'm well aware this violates the Law of Least Surprise, but it was done ages ago and is now so baked into our code that extracting it would be a major undertaking.)The current code "splats" the
target
ofturbo_stream_action_tag
to pass to thedom_id
method. The problem is that it's assuming that the object is "array-like" - which theArray()
method does not ensure. It usesto_ary
orto_a
to return an array, but doesn't indicate that the object itself is in fact an array.This PR fixes this by using
Array.wrap
, ensuring we actually have an array, and splatting the array into the method rather than the original target (which would callto_a
again).I wasn't able to find a contribution guideline page, so please let me know if anything else needs to be done here (do I need to create an issue?)