Updated active_record_querying.md

Added the SQL equivalent of the find_by method

Update active_record_querying.md

Update active_record_querying.md
This commit is contained in:
Ahmad Al-kheat 2015-01-12 16:50:17 -05:00 committed by Ahmad
parent 72570ea289
commit edbc9468d5

@ -257,6 +257,12 @@ It is equivalent to writing:
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:
```ruby