aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWillian Gustavo Veiga <beberveiga@gmail.com>2018-10-04 21:43:26 -0300
committerWillian Gustavo Veiga <beberveiga@gmail.com>2018-10-04 21:43:49 -0300
commit4b60e34f58c0dabe18a793038fc7775d044016f6 (patch)
tree584ceee14c151a237980c11edbe20a0e577c8218
parent43eabac605fedae72bd885c1d3861a6d1bfad3e0 (diff)
downloadrails-4b60e34f58c0dabe18a793038fc7775d044016f6.tar.gz
rails-4b60e34f58c0dabe18a793038fc7775d044016f6.tar.bz2
rails-4b60e34f58c0dabe18a793038fc7775d044016f6.zip
Mention reselect new method in the "Active Record Query Interface" guide
-rw-r--r--guides/source/active_record_querying.md26
1 files changed, 26 insertions, 0 deletions
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: