From 67d88b5040e93672c4122817a8e3b21720b2d9fd Mon Sep 17 00:00:00 2001 From: Sergio Date: Wed, 4 Sep 2013 16:50:10 +0200 Subject: Example of Join models In the example of join models, there are five models but in the explanation only consider Category, Post, Comment and Guest. --- guides/source/active_record_querying.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source/active_record_querying.md') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index ba0dc6d9eb..ba0260c13c 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 -- cgit v1.2.3 From 90155b4e28a3887dce9428e9df150ede3d6c7465 Mon Sep 17 00:00:00 2001 From: Sergio Date: Thu, 5 Sep 2013 00:40:14 +0200 Subject: Client.exists?(1,2,3) and Client.exists?([1,2,3]) does not work The right command for doing that is Client.exists?id:[1,2,3] Exists does not work like find method, in find method you can do Person.find(1, 2, 6) or Person.find([7, 17]) but not Person.exists?(1,2,3) or Person.exists?([1,2,3]) --- guides/source/active_record_querying.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'guides/source/active_record_querying.md') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index ba0260c13c..6c06399673 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -1514,9 +1514,9 @@ 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. ```ruby -Client.exists?(1,2,3) -# or -Client.exists?([1,2,3]) +Client.exists?id:[1,2,3] +or +Client.exists?name:['John','Sergei'] ``` It's even possible to use `exists?` without any arguments on a model or a relation. -- cgit v1.2.3 From 0d2d10d8c4f5dd906e40a91fbf9781d915727acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 4 Sep 2013 20:48:15 -0300 Subject: Review the changes made on 90155b4e28a3887dce9428e9df150ede3d6c7465 --- guides/source/active_record_querying.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'guides/source/active_record_querying.md') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 6c06399673..cb5fe52506 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -1505,18 +1505,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?id:[1,2,3] +Client.exists?(id: [1,2,3]) or -Client.exists?name:['John','Sergei'] +Client.exists?(name: ['John', 'Sergei']) ``` It's even possible to use `exists?` without any arguments on a model or a relation. @@ -1525,7 +1528,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? -- cgit v1.2.3 From a78a4652c2f5ec76d3a9ed91f80789716b99a37c Mon Sep 17 00:00:00 2001 From: Sergio Date: Thu, 5 Sep 2013 12:04:37 +0200 Subject: added # or comment --- guides/source/active_record_querying.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source/active_record_querying.md') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index cb5fe52506..2df6b0ba6a 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -1518,7 +1518,7 @@ one of those records exists. ```ruby Client.exists?(id: [1,2,3]) -or +# or Client.exists?(name: ['John', 'Sergei']) ``` -- cgit v1.2.3