Skip to content

Commit

Permalink
Update the documentation for find_by method
Browse files Browse the repository at this point in the history
  • Loading branch information
bodhish committed Oct 1, 2021
1 parent 5446842 commit b1e8b5e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions guides/source/active_record_querying.md
Expand Up @@ -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
Expand Down

0 comments on commit b1e8b5e

Please sign in to comment.