1
0
Fork 0
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:
peeyush 2014-05-22 23:07:18 +05:30
parent 9ca4839a1a
commit 42c55b9380

View file

@ -753,13 +753,15 @@ Article.find(10).comments.reorder('name')
The SQL that would be executed: The SQL that would be executed:
```sql ```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: In case the `reorder` clause is not used, the SQL executed would be:
```sql ```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` ### `reverse_order`