aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_record_querying.md
diff options
context:
space:
mode:
authorAhmad Al-kheat <wisamfaithful@gmail.com>2015-01-12 16:50:17 -0500
committerAhmad <wisamfaithful@gmail.com>2015-01-12 18:19:48 -0500
commitedbc9468d54dba47ca10e1b53c5725d6bd6c50e5 (patch)
tree97c7c43aae428c1ad8e0d96c8b00883f8bebe0ac /guides/source/active_record_querying.md
parent72570ea289ca96edbc074c3aadb2be2b214303af (diff)
downloadrails-edbc9468d54dba47ca10e1b53c5725d6bd6c50e5.tar.gz
rails-edbc9468d54dba47ca10e1b53c5725d6bd6c50e5.tar.bz2
rails-edbc9468d54dba47ca10e1b53c5725d6bd6c50e5.zip
Updated active_record_querying.md
Added the SQL equivalent of the find_by method Update active_record_querying.md Update active_record_querying.md
Diffstat (limited to 'guides/source/active_record_querying.md')
-rw-r--r--guides/source/active_record_querying.md6
1 files changed, 6 insertions, 0 deletions
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