aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_record_querying.md
diff options
context:
space:
mode:
authorVipul A M <vipulnsward@gmail.com>2013-11-25 12:00:46 +0530
committerVipul A M <vipulnsward@gmail.com>2013-11-25 12:00:46 +0530
commit66087189c1aa14b91383c25fcf8762bb58c6e2b3 (patch)
tree5de913070d833593e87a725f9589639fdd177cfc /guides/source/active_record_querying.md
parent587c2d67ce3279f79b00a23db9c2f42ae59af548 (diff)
downloadrails-66087189c1aa14b91383c25fcf8762bb58c6e2b3.tar.gz
rails-66087189c1aa14b91383c25fcf8762bb58c6e2b3.tar.bz2
rails-66087189c1aa14b91383c25fcf8762bb58c6e2b3.zip
Added `rewhere` usage to AR querying guides
Diffstat (limited to 'guides/source/active_record_querying.md')
-rw-r--r--guides/source/active_record_querying.md26
1 files changed, 26 insertions, 0 deletions
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
-------------