aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_record_querying.md
diff options
context:
space:
mode:
Diffstat (limited to 'guides/source/active_record_querying.md')
-rw-r--r--guides/source/active_record_querying.md14
1 files changed, 10 insertions, 4 deletions
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index 18a5342a2f..7fe9b8b4af 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -514,7 +514,13 @@ SELECT * FROM clients WHERE (clients.orders_count IN (1,3,5))
Post.where.not(author: author)
```
-In other words, this query can be generated by calling `where` with no argument, then immediately chain with `not` passing `where` conditions.
+In other words, this query can be generated by calling `where` with no argument,
+then immediately chain with `not` passing `where` conditions. This will generate
+SQL code like this:
+
+```sql
+SELECT * FROM posts WHERE (author_id != 1)
+```
Ordering
--------
@@ -543,11 +549,11 @@ Client.order("orders_count ASC, created_at DESC")
Client.order("orders_count ASC", "created_at DESC")
```
-If you want to call `order` multiple times e.g. in different context, new order will prepend previous one
+If you want to call `order` multiple times e.g. in different context, new order will append previous one
```ruby
Client.order("orders_count ASC").order("created_at DESC")
-# SELECT * FROM clients ORDER BY created_at DESC, orders_count ASC
+# SELECT * FROM clients ORDER BY orders_count ASC, created_at DESC
```
Selecting Specific Fields
@@ -711,7 +717,7 @@ Post.order('id DESC').limit(20).unscope(:order, :limit) = Post.all
You can additionally unscope specific where clauses. For example:
```ruby
-Post.where(id: 10).limit(1).unscope(:where, :limit).order('id DESC') = Post.order('id DESC')
+Post.where(id: 10).limit(1).unscope({ where: :id }, :limit).order('id DESC') = Post.order('id DESC')
```
### `only`