What’s the difference between to_a and to_ary in ActiveRecord?

What’s the difference between ActiveRecord.to_a and ActiveRecord.to_ary?


to_a, when called on an object returns an array representation of obj

Examples

class Example
  def initialize
    @str = 'example'
  end
end
a = Example.new #=> #<Example:0x105a74af8 @str="example"
a.to_a #=> [#<Example:0x105a6a3a0 @str="example">]

Hash Example

h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 }
h.to_a #=> [["c", 300], ["a", 100], ["d", 400]]

An array can also be created by using the Array() method, provided by Kernel, which tries to call to_ary, then to_a on its argument. http://ruby-doc.org/core-2.0/Array.html#method-i-to_ary

so as far as I can see, the Array#to_ary src just returns the array that is passed in, as in

def to_ary
  return self
end

if I understand correctly, to_a is used for array conversion and makes its final return using to_ary. But this may not be true in future versions according to apidock

to_a Returns an array representation of obj. For objects of class Object and others that don’t explicitly override the method, the return value is an array containing self. However, this latter behavior will soon be obsolete. http://apidock.com/ruby/Object/to_a