From 98bfccbdb5c29060f5e042819669b7442b6cd56c Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Thu, 17 May 2012 01:32:21 +0530 Subject: [PATCH] document the AR::Base#ids method introduced in 9307616 [ci skip] --- guides/source/active_record_querying.textile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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) +h3. +ids+ + ++ids+ can be used to pluck all the IDs for the relation using the table's primary key. + + +Person.ids +# SELECT id FROM people + + + +class Person < ActiveRecord::Base + self.primary_key = "person_id" +end + +Person.ids +# SELECT person_id FROM people + + 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+.