mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
resolved reorder issue in rails active record guide
This commit is contained in:
parent
9ca4839a1a
commit
42c55b9380
1 changed files with 4 additions and 2 deletions
|
@ -753,13 +753,15 @@ Article.find(10).comments.reorder('name')
|
|||
The SQL that would be executed:
|
||||
|
||||
```sql
|
||||
SELECT * FROM articles WHERE id = 10 ORDER BY name
|
||||
SELECT * FROM articles WHERE id = 10
|
||||
SELECT * FROM comments WHERE article_id = 10 ORDER BY name
|
||||
```
|
||||
|
||||
In case the `reorder` clause is not used, the SQL executed would be:
|
||||
|
||||
```sql
|
||||
SELECT * FROM articles WHERE id = 10 ORDER BY posted_at DESC
|
||||
SELECT * FROM articles WHERE id = 10
|
||||
SELECT * FROM comments WHERE article_id = 10 ORDER BY posted_at DESC
|
||||
```
|
||||
|
||||
### `reverse_order`
|
||||
|
|
Loading…
Reference in a new issue