resolved reorder issue in rails active record guide

This commit is contained in:
peeyush 2014-05-22 23:07:18 +05:30
parent 9ca4839a1a
commit 42c55b9380
1 changed files with 4 additions and 2 deletions

View File

@ -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`