Update the documentation for find_by method

This commit is contained in:
Bodhish Thomas 2021-10-01 14:11:29 +05:30
parent 5446842968
commit b1e8b5ebc7
1 changed files with 2 additions and 0 deletions

View File

@ -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