From 4cf21093e83984eb4ff39cc23e0338023fa7ea5f Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sat, 7 Feb 2009 16:11:01 +0000 Subject: Add options to the arg list --- railties/guides/source/active_record_querying.textile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'railties/guides/source/active_record_querying.textile') diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile index 9ab8266d2e..a28af04301 100644 --- a/railties/guides/source/active_record_querying.textile +++ b/railties/guides/source/active_record_querying.textile @@ -71,7 +71,7 @@ Active Record lets you retrieve a single object using three different ways. h5. Using a primary key -Using Model.find(primary_key), you can retrieve the object corresponding to the supplied _primary key_. For example: +Using Model.find(primary_key, options = nil), you can retrieve the object corresponding to the supplied _primary key_ and matching the supplied options (if any). For example: # Find the client with primary key (id) 10. @@ -131,7 +131,7 @@ h4. Retrieving Multiple Objects h5. Using multiple primary keys -Model.find(array_of_primary_key) also accepts an array of _primary keys_. An array of all the matching records for the supplied _primary keys_ is returned. For example: +Model.find(array_of_primary_key, options = nil) also accepts an array of _primary keys_. An array of all the matching records for the supplied _primary keys_ is returned. For example: # Find the clients with primary keys 1 and 10. @@ -165,6 +165,8 @@ SELECT * FROM clients Model.all returns an empty array +[]+ if no matching record is found. No exception will be raised. +NOTE: +Model.find(:all, options)+ is equivalent to +Model.all(options)+ + h3. Conditions The +find+ method allows you to specify conditions to limit the records returned. You can specify conditions as a string, array, or hash. -- cgit v1.2.3