From db45df361a38112dd67a861a18d0b60c3dd6ae6a Mon Sep 17 00:00:00 2001 From: r11runner Date: Sat, 31 Oct 2015 23:36:27 +0100 Subject: [PATCH] [ci skip] querying guide methods first and last: mentioning the influence of the default scope --- guides/source/active_record_querying.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index b7773ea65a..ec31fa9d67 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -185,6 +185,8 @@ SELECT * FROM clients ORDER BY clients.id ASC LIMIT 1 The `first` method returns `nil` if no matching record is found and no exception will be raised. +If your [default scope](active_record_querying.html#applying-a-default-scope) contains an order method, `first` will return the first record according to this ordering. + You can pass in a numerical argument to the `first` method to return up to that number of results. For example ```ruby @@ -221,6 +223,8 @@ SELECT * FROM clients ORDER BY clients.id DESC LIMIT 1 The `last` method returns `nil` if no matching record is found and no exception will be raised. +If your [default scope](active_record_querying.html#applying-a-default-scope) contains an order method, `last` will return the last record according to this ordering. + You can pass in a numerical argument to the `last` method to return up to that number of results. For example ```ruby