diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-10-12 19:37:02 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-12 19:37:02 +0900 |
commit | 8bcb4fab366611d3e9b34690682415281440c128 (patch) | |
tree | e0ae988f9bc96c9ddbcfc672a420a14287187d44 /guides | |
parent | fcb84298ce04f10e713c92792c758e9cb142f799 (diff) | |
parent | 0efc132a8153dbaf0951ce55457abe43dd5a309b (diff) | |
download | rails-8bcb4fab366611d3e9b34690682415281440c128.tar.gz rails-8bcb4fab366611d3e9b34690682415281440c128.tar.bz2 rails-8bcb4fab366611d3e9b34690682415281440c128.zip |
Merge pull request #30867 from aditya-kapoor/guide-select_all-fix
fix the description for the `select_all` [ci skip]
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/active_record_querying.md | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 3573c3c77b..3786343fc3 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -1712,10 +1712,10 @@ 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. Instead, you will get 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_hash` 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'") +Client.connection.select_all("SELECT first_name, created_at FROM clients WHERE id = '1'").to_hash # => [ # {"first_name"=>"Rafael", "created_at"=>"2012-11-10 23:23:45.281189"}, # {"first_name"=>"Eileen", "created_at"=>"2013-12-09 11:22:35.221282"} |