From 4b60e34f58c0dabe18a793038fc7775d044016f6 Mon Sep 17 00:00:00 2001 From: Willian Gustavo Veiga Date: Thu, 4 Oct 2018 21:43:26 -0300 Subject: Mention reselect new method in the "Active Record Query Interface" guide --- guides/source/active_record_querying.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'guides') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 02055e59f0..18aa179d03 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -805,6 +805,32 @@ SELECT * FROM articles WHERE id > 10 ORDER BY id DESC LIMIT 20 ``` +### `reselect` + +The `reselect` method overrides an existing select statement. For example: + +```ruby +Post.select(:title, :body).reselect(:created_at) +``` + +The SQL that would be executed: + +```sql +SELECT `posts.created_at` FROM `posts` +``` + +In case the `reselect` clause is not used, + +```ruby +Post.select(:title, :body) +``` + +the SQL executed would be: + +```sql +SELECT `posts.title`, `posts.body` FROM `posts` +``` + ### `reorder` The `reorder` method overrides the default scope order. For example: -- cgit v1.2.3