diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile index 009d541106830..484ba796bdf23 100644 --- a/railties/guides/source/active_record_querying.textile +++ b/railties/guides/source/active_record_querying.textile @@ -130,6 +130,40 @@ SELECT * FROM clients ORDER BY clients.id DESC LIMIT 1 Model.last returns +nil+ if no matching record is found. No exception will be raised. +h5. +first!+ + +Model.first! finds the first record matched by the supplied options. For example: + + +client = Client.first! +=> # + + +SQL equivalent of the above is: + + +SELECT * FROM clients LIMIT 1 + + +Model.first! raises +RecordNotFound+ if no matching record is found. + +h5. +last!+ + +Model.last! finds the last record matched by the supplied options. For example: + + +client = Client.last! +=> # + + +SQL equivalent of the above is: + + +SELECT * FROM clients ORDER BY clients.id DESC LIMIT 1 + + +Model.last! raises +RecordNotFound+ if no matching record is found. + h4. Retrieving Multiple Objects h5. Using Multiple Primary Keys