aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2012-05-17 01:32:21 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2012-05-17 01:34:00 +0530
commit98bfccbdb5c29060f5e042819669b7442b6cd56c (patch)
treee66030e08b56b35567325906f255a4d5a7e32ee2 /guides
parente8feaff60b9c04d34ad234f7d17b5d2ad9cc7a24 (diff)
downloadrails-98bfccbdb5c29060f5e042819669b7442b6cd56c.tar.gz
rails-98bfccbdb5c29060f5e042819669b7442b6cd56c.tar.bz2
rails-98bfccbdb5c29060f5e042819669b7442b6cd56c.zip
document the AR::Base#ids method introduced in 9307616 [ci skip]
Diffstat (limited to 'guides')
-rw-r--r--guides/source/active_record_querying.textile18
1 files changed, 18 insertions, 0 deletions
diff --git a/guides/source/active_record_querying.textile b/guides/source/active_record_querying.textile
index a9cb424eaa..294ef25b33 100644
--- a/guides/source/active_record_querying.textile
+++ b/guides/source/active_record_querying.textile
@@ -1260,6 +1260,24 @@ with
Client.pluck(:id)
</ruby>
+h3. +ids+
+
++ids+ can be used to pluck all the IDs for the relation using the table's primary key.
+
+<ruby>
+Person.ids
+# SELECT id FROM people
+</ruby>
+
+<ruby>
+class Person < ActiveRecord::Base
+ self.primary_key = "person_id"
+end
+
+Person.ids
+# SELECT person_id FROM people
+</ruby>
+
h3. 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+.