diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-02-07 16:11:01 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-02-07 16:11:01 +0000 |
commit | 4cf21093e83984eb4ff39cc23e0338023fa7ea5f (patch) | |
tree | 4e1d2c3e133de16942ec224787bf6de41cf653b1 /railties/guides/source/active_record_querying.textile | |
parent | 9fd8538ca47e311086707f436ce447995365919c (diff) | |
download | rails-4cf21093e83984eb4ff39cc23e0338023fa7ea5f.tar.gz rails-4cf21093e83984eb4ff39cc23e0338023fa7ea5f.tar.bz2 rails-4cf21093e83984eb4ff39cc23e0338023fa7ea5f.zip |
Add options to the arg list
Diffstat (limited to 'railties/guides/source/active_record_querying.textile')
-rw-r--r-- | railties/guides/source/active_record_querying.textile | 6 |
1 files changed, 4 insertions, 2 deletions
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 <tt>Model.find(primary_key)</tt>, you can retrieve the object corresponding to the supplied _primary key_. For example: +Using <tt>Model.find(primary_key, options = nil)</tt>, you can retrieve the object corresponding to the supplied _primary key_ and matching the supplied options (if any). For example: <ruby> # Find the client with primary key (id) 10. @@ -131,7 +131,7 @@ h4. Retrieving Multiple Objects h5. Using multiple primary keys -<tt>Model.find(array_of_primary_key)</tt> also accepts an array of _primary keys_. An array of all the matching records for the supplied _primary keys_ is returned. For example: +<tt>Model.find(array_of_primary_key, options = nil)</tt> also accepts an array of _primary keys_. An array of all the matching records for the supplied _primary keys_ is returned. For example: <ruby> # Find the clients with primary keys 1 and 10. @@ -165,6 +165,8 @@ SELECT * FROM clients <tt>Model.all</tt> 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. |