aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_record_querying.md
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2013-09-13 00:22:42 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2013-09-13 00:22:42 +0530
commitd262773ab7f0aae5de2d354ac2eca168e95b653d (patch)
treea8d6c05c8e47d318ed7ec6ca5c2a74c09ce8c176 /guides/source/active_record_querying.md
parentab5cd54b7e791f8419f689d1bef5394890268a6f (diff)
parent3199b842014b6b384adfa8a9d69d48995b5383ef (diff)
downloadrails-d262773ab7f0aae5de2d354ac2eca168e95b653d.tar.gz
rails-d262773ab7f0aae5de2d354ac2eca168e95b653d.tar.bz2
rails-d262773ab7f0aae5de2d354ac2eca168e95b653d.zip
Merge branch 'master' of github.com:rails/docrails
Diffstat (limited to 'guides/source/active_record_querying.md')
-rw-r--r--guides/source/active_record_querying.md16
1 files changed, 10 insertions, 6 deletions
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index 5aa935a155..28013beeae 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -943,7 +943,7 @@ WARNING: This method only works with `INNER JOIN`.
Active Record lets you use the names of the [associations](association_basics.html) defined on the model as a shortcut for specifying `JOIN` clause for those associations when using the `joins` method.
-For example, consider the following `Category`, `Post`, `Comments` and `Guest` models:
+For example, consider the following `Category`, `Post`, `Comment`, `Guest` and `Tag` models:
```ruby
class Category < ActiveRecord::Base
@@ -1536,18 +1536,21 @@ Person.ids
Existence of Objects
--------------------
-If you simply want to check for the existence of the object there's a method called `exists?`. This method will query the database using the same query as `find`, but instead of returning an object or collection of objects it will return either `true` or `false`.
+If you simply want to check for the existence of the object there's a method called `exists?`.
+This method will query the database using the same query as `find`, but instead of returning an
+object or collection of objects it will return either `true` or `false`.
```ruby
Client.exists?(1)
```
-The `exists?` method also takes multiple ids, but the catch is that it will return true if any one of those records exists.
+The `exists?` method also takes multiple values, but the catch is that it will return `true` if any
+one of those records exists.
```ruby
-Client.exists?(1,2,3)
+Client.exists?(id: [1,2,3])
# or
-Client.exists?([1,2,3])
+Client.exists?(name: ['John', 'Sergei'])
```
It's even possible to use `exists?` without any arguments on a model or a relation.
@@ -1556,7 +1559,8 @@ It's even possible to use `exists?` without any arguments on a model or a relati
Client.where(first_name: 'Ryan').exists?
```
-The above returns `true` if there is at least one client with the `first_name` 'Ryan' and `false` otherwise.
+The above returns `true` if there is at least one client with the `first_name` 'Ryan' and `false`
+otherwise.
```ruby
Client.exists?