Deleted my double-posted message, also just to add for clarity: My 
suggestion is to deprecate/remove the ActiveRecord::Result#to_hash method, 
replacing all instances with #to_a or Array.wrap(result).

On Friday, January 22, 2016 at 10:10:34 AM UTC-8, Kache wrote:
>
> Was about to open a GitHub issue, but found this mailing list
>
> [ActiveRecord::Result#to_hash](
> https://github.com/rails/rails/commit/59f7780a3454a14054d1d33d9b6e31192ab2e58b#diff-56dacac8e4a23c4e1d4f63562fa5d6d1R23
> )
>
> It's unexpected for `#to_hash` to _not_ return a hash, e.g. [AwesomePrint](
> https://github.com/michaeldv/awesome_print) checks and uses `#to_hash` to 
> inspect hash-convertible objects, as noted in [an AwesomePrint issue](
> https://github.com/michaeldv/awesome_print/issues/215).
>
> Ruby core even expects `Hash` from `#to_hash`:
>
>     > Hash.try_convert(ActiveRecord::Base.connection.select_all("select * 
> from users limit 1;"))
>     TypeError: can't convert ActiveRecord::Result to Hash 
> (ActiveRecord::Result#to_hash gives Array)
>
> `#to_ary` already exists, meaning users of `ActiveRecord::Result#to_hash` 
> should really be using `ActiveRecord::Result#to_a`
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to