mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #18471 from ahmad-alkheat/master
Added the SQL equivalent of the find_by method. [ci skip]
This commit is contained in:
commit
233029e90c
1 changed files with 6 additions and 0 deletions
|
@ -257,6 +257,12 @@ It is equivalent to writing:
|
||||||
Client.where(first_name: 'Lifo').take
|
Client.where(first_name: 'Lifo').take
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The SQL equivalent of the above is:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT * FROM clients WHERE (clients.first_name = 'Lifo') LIMIT 1
|
||||||
|
```
|
||||||
|
|
||||||
The `find_by!` method behaves exactly like `find_by`, except that it will raise `ActiveRecord::RecordNotFound` if no matching record is found. For example:
|
The `find_by!` method behaves exactly like `find_by`, except that it will raise `ActiveRecord::RecordNotFound` if no matching record is found. For example:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
|
|
Loading…
Reference in a new issue