From edbc9468d54dba47ca10e1b53c5725d6bd6c50e5 Mon Sep 17 00:00:00 2001 From: Ahmad Al-kheat Date: Mon, 12 Jan 2015 16:50:17 -0500 Subject: [PATCH] Updated active_record_querying.md Added the SQL equivalent of the find_by method Update active_record_querying.md Update active_record_querying.md --- guides/source/active_record_querying.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index f8c64cbd0c..f7ea72b68d 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -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 -- GitLab