aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-03-17 03:41:12 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-03-17 03:41:12 +0900
commit6486f80d3a3448579089fab1c8b7846c09cf87ec (patch)
tree93ed6aa961f4c2031b25b410688135a2acabf66f /guides
parent728ba13a5dcfabc2cba85ce8fed05544c46584a0 (diff)
downloadrails-6486f80d3a3448579089fab1c8b7846c09cf87ec.tar.gz
rails-6486f80d3a3448579089fab1c8b7846c09cf87ec.tar.bz2
rails-6486f80d3a3448579089fab1c8b7846c09cf87ec.zip
`ActiveRecord::Result#to_hash` has been renamed to `to_a` [ci skip]
See #33912.
Diffstat (limited to 'guides')
-rw-r--r--guides/source/active_record_querying.md7
1 files changed, 5 insertions, 2 deletions
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index 24dea0ec46..4675730bd0 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -1731,10 +1731,13 @@ Client.find_by_sql("SELECT * FROM clients
### `select_all`
-`find_by_sql` has a close relative called `connection#select_all`. `select_all` will retrieve objects from the database using custom SQL just like `find_by_sql` but will not instantiate them. This method will return an instance of `ActiveRecord::Result` class and calling `to_hash` on this object would return you an array of hashes where each hash indicates a record.
+`find_by_sql` has a close relative called `connection#select_all`. `select_all` will retrieve
+objects from the database using custom SQL just like `find_by_sql` but will not instantiate them.
+This method will return an instance of `ActiveRecord::Result` class and calling `to_a` on this
+object would return you an array of hashes where each hash indicates a record.
```ruby
-Client.connection.select_all("SELECT first_name, created_at FROM clients WHERE id = '1'").to_hash
+Client.connection.select_all("SELECT first_name, created_at FROM clients WHERE id = '1'").to_a
# => [
# {"first_name"=>"Rafael", "created_at"=>"2012-11-10 23:23:45.281189"},
# {"first_name"=>"Eileen", "created_at"=>"2013-12-09 11:22:35.221282"}