aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-05-25 22:25:36 +0900
committerGitHub <noreply@github.com>2017-05-25 22:25:36 +0900
commitee14c1b85028e103404f08da364d451863bb18e3 (patch)
tree46bcbf65b1964a52863bb2e793d5d6dfa1535fd4 /guides/source
parent7424a179d61c15fcbd2a2d9937202520c878b2ff (diff)
parentaf41b98577a09c9177b0fae76b7d07d787d02ce3 (diff)
downloadrails-ee14c1b85028e103404f08da364d451863bb18e3.tar.gz
rails-ee14c1b85028e103404f08da364d451863bb18e3.tar.bz2
rails-ee14c1b85028e103404f08da364d451863bb18e3.zip
Merge pull request #29225 from maicher/master
Add ActiveRecord::Relation#or description to guides
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/active_record_querying.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index 26d01d4ede..d1cbe506b4 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -557,6 +557,19 @@ In other words, this query can be generated by calling `where` with no argument,
SELECT * FROM clients WHERE (clients.locked != 1)
```
+### OR Conditions
+
+`OR` condition between two relations can be build by calling `or` on the first relation
+and passing the second one as an argument.
+
+```ruby
+Client.where(locked: true).or(Client.where(orders_count: [1,3,5]))
+```
+
+```sql
+SELECT * FROM clients WHERE (clients.locked = 1 OR clients.orders_count IN (1,3,5))
+```
+
Ordering
--------