Hi all,

Good to see Array.wrap get added.  However it 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 short-term solution the coder who hit this suggested was to add a
case to the #wrap:

          when ActiveRecord::NamedScope::Scope,
ActiveRecord::Associations::AssociationCollection
            object.to_a

But this has the effect of loading ActiveRecord from ActiveSupport,
which is undesirable.  Is there a better way to detect
association-collection-ness?

I'm thinking that it might be better to check for the #to_ary method
on all objects and use that instead, without having a special case for
collections/scopes.  Does that sound OK?  If so I'll submit a patch.

Cheers,
Will

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to