diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-01-13 13:20:08 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-01-13 13:20:08 -0200 |
commit | 233029e90ccd57eefc024ffa2f1b6ff317300a4e (patch) | |
tree | 926593cf1082524f829636e2a5b0ab75f25383eb /guides/source/active_record_querying.md | |
parent | 19b4b0dff1820b13db35b7a75dfb7d06f7240ecf (diff) | |
parent | edbc9468d54dba47ca10e1b53c5725d6bd6c50e5 (diff) | |
download | rails-233029e90ccd57eefc024ffa2f1b6ff317300a4e.tar.gz rails-233029e90ccd57eefc024ffa2f1b6ff317300a4e.tar.bz2 rails-233029e90ccd57eefc024ffa2f1b6ff317300a4e.zip |
Merge pull request #18471 from ahmad-alkheat/master
Added the SQL equivalent of the find_by method. [ci skip]
Diffstat (limited to 'guides/source/active_record_querying.md')
-rw-r--r-- | guides/source/active_record_querying.md | 6 |
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 |