Skip to content

Commit 80e31d2

Browse files
committed
Make ActiveRecord::Result#to_a as alias to ActiveRecord::Result#to_ary
`ActiveRecord::Result#to_a` was introduced in rails#33912. I would prefer to make `to_a` as alias to the `to_ary` because: - It would be clear for users from https://edgeapi.rubyonrails.org/classes/ActiveRecord/Result.html that `to_a` and `to_ary` are the same - For us it would take less efforts in case if we needed to change the docs or implementation, since the methods are the same Follow up rails#33912
1 parent f1dcfc6 commit 80e31d2

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

activerecord/lib/active_record/result.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ def each
6565
end
6666
end
6767

68-
# Returns an array of hashes representing each row record.
69-
def to_a
70-
hash_rows
71-
end
72-
7368
def to_hash
7469
ActiveSupport::Deprecation.warn(<<-MSG.squish)
7570
`ActiveRecord::Result#to_hash` has been renamed to `to_a`.
@@ -91,6 +86,8 @@ def to_ary
9186
hash_rows
9287
end
9388

89+
alias :to_a :to_ary
90+
9491
def [](idx)
9592
hash_rows[idx]
9693
end

0 commit comments

Comments
 (0)