diff options
author | Willian Gustavo Veiga <beberveiga@gmail.com> | 2018-10-04 21:43:26 -0300 |
---|---|---|
committer | Willian Gustavo Veiga <beberveiga@gmail.com> | 2018-10-04 21:43:49 -0300 |
commit | 4b60e34f58c0dabe18a793038fc7775d044016f6 (patch) | |
tree | 584ceee14c151a237980c11edbe20a0e577c8218 | |
parent | 43eabac605fedae72bd885c1d3861a6d1bfad3e0 (diff) | |
download | rails-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.md | 26 |
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: |