From 66087189c1aa14b91383c25fcf8762bb58c6e2b3 Mon Sep 17 00:00:00 2001
From: Vipul A M <vipulnsward@gmail.com>
Date: Mon, 25 Nov 2013 12:00:46 +0530
Subject: Added `rewhere` usage to AR querying guides

---
 guides/source/active_record_querying.md | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

(limited to 'guides/source')

diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index bdfcfd92ce..94b8453f04 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -790,6 +790,32 @@ SELECT * FROM clients WHERE orders_count > 10 ORDER BY clients.id DESC
 
 This method accepts **no** arguments.
 
+### `rewhere`
+
+The `rewhere` method overrides an existing, named where condition. For example:
+
+```ruby
+Post.where(trashed: true).rewhere(trashed: false)
+```
+
+The SQL that would be executed:
+
+```sql
+SELECT * FROM posts WHERE `trashed` = 0
+```
+
+In case the `rewhere` clause is not used,
+
+```ruby
+Post.where(trashed: true).where(trashed: false)
+```
+
+the SQL executed would be:
+
+```sql
+SELECT * FROM posts WHERE `trashed` = 1 AND `trashed` = 0
+```
+
 Null Relation
 -------------
 
-- 
cgit v1.2.3