1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
This commit is contained in:
Rafael Mendonça França 2020-08-25 22:03:50 +00:00
parent 14bd328273
commit e71d09bf82
No known key found for this signature in database
GPG key ID: FC23B6D0F1EEE948

View file

@ -1609,7 +1609,7 @@ you get the instance method `find_by_first_name` for free from Active Record.
If you also have a `locked` field on the `Customer` model, you also get `find_by_locked` method.
You can specify an exclamation point (`!`) on the end of the dynamic finders
gto get them to raise an `ActiveRecord::RecordNotFound` error if they do not return any records, like `Customer.find_by_name!("Ryan")`
to get them to raise an `ActiveRecord::RecordNotFound` error if they do not return any records, like `Customer.find_by_name!("Ryan")`
If you want to find both by `name` and `orders_count`, you can chain these finders together by simply typing "`and`" between the fields.
For example, `Customer.find_by_first_name_and_orders_count("Ryan", 5)`.