Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Array.wrap handling of association collections

#1935

Array.wrap doesn't DWIM with associations:

Array.wrap(Icp.find(16).registers) => [[#<Register ...>]]

Array.wrap(DisputedRead.unresolved) => [[#<DisputedRead ...>, #<DisputedRead ...>]]

ie. array-like collections and scopes aren't getting treated as arrays and are being wrapped again.

The attached patch checks if the given object responds to to_ary, and if so returns that.

Reported by Will Bryant · February 11th, 2009 @ 01:55 AM

State: committed
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Repository
    Repository
    • State changed from new to committed

    (from [1a2a71333f197e98d1cd7fe380d613cbada4446b]) Array#wrap should use #to_ary so association collections and named scopes are not re-wrapped

    [#1935 Array.wrap handling of association collections state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net http://github.com/rails/rails/co...

    February 11th, 2009 @ 02:03 AM