aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_record_querying.md
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2015-11-02 09:08:38 -0500
committerYves Senn <yves.senn@gmail.com>2015-11-02 09:08:38 -0500
commit63c014547efb6bce6945d09aa4f14dc50a54b71d (patch)
tree68e7007e3e868a56be81d4171e069900b99ac9ee /guides/source/active_record_querying.md
parentab3510367bd4622f836374e5a37e54381ea72fc6 (diff)
parentdb45df361a38112dd67a861a18d0b60c3dd6ae6a (diff)
downloadrails-63c014547efb6bce6945d09aa4f14dc50a54b71d.tar.gz
rails-63c014547efb6bce6945d09aa4f14dc50a54b71d.tar.bz2
rails-63c014547efb6bce6945d09aa4f14dc50a54b71d.zip
Merge pull request #22142 from r11runner/query-guide-first-last-default-scope
[ci skip] querying guide methods first and last: mentioning the influence of the default scope
Diffstat (limited to 'guides/source/active_record_querying.md')
-rw-r--r--guides/source/active_record_querying.md4
1 files changed, 4 insertions, 0 deletions
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