From b1e8b5ebc7e381d922d477950f81f664f4aa1324 Mon Sep 17 00:00:00 2001 From: Bodhish Thomas Date: Fri, 1 Oct 2021 14:11:29 +0530 Subject: [PATCH] Update the documentation for find_by method --- guides/source/active_record_querying.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 99259c25f2..ec62bd04d1 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -358,6 +358,8 @@ The SQL equivalent of the above is: SELECT * FROM customers WHERE (customers.first_name = 'Lifo') LIMIT 1 ``` +Note that there is no `ORDER BY` in the above SQL. If your `find_by` conditions can match multiple records, you should [apply an order](#ordering) to guarantee a deterministic result. + The [`find_by!`][] method behaves exactly like `find_by`, except that it will raise `ActiveRecord::RecordNotFound` if no matching record is found. For example: ```irb