aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-01-16 22:09:37 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-01-16 22:12:37 -0200
commit7252b43c6ecd31a023399085165b1cea9d1306f5 (patch)
tree10c3eefd74bf01dc6d6f66c4edbd66b386aa0020 /guides
parentb9acc4a838e3affe241a7a1f359efe94b6caab5e (diff)
downloadrails-7252b43c6ecd31a023399085165b1cea9d1306f5.tar.gz
rails-7252b43c6ecd31a023399085165b1cea9d1306f5.tar.bz2
rails-7252b43c6ecd31a023399085165b1cea9d1306f5.zip
Only some dynamic finders are deprecated.
find_by_* and find_by_*! are not deprecated for example, so lets add a note only where it is needed [ci skip]
Diffstat (limited to 'guides')
-rw-r--r--guides/source/active_record_querying.md10
1 files changed, 5 insertions, 5 deletions
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index 4725e2c8a2..3783be50c0 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -1338,11 +1338,6 @@ Client.unscoped {
Dynamic Finders
---------------
-NOTE: Dynamic finders have been deprecated in Rails 4.0 and will be
-removed in Rails 4.1. The best practice is to use Active Record scopes
-instead. You can find the deprecation gem at
-https://github.com/rails/activerecord-deprecated_finders
-
For every field (also known as an attribute) you define in your table, Active Record provides a finder method. If you have a field called `first_name` on your `Client` model for example, you get `find_by_first_name` for free from Active Record. If you have a `locked` field on the `Client` model, you also get `find_by_locked` and methods.
You can specify an exclamation point (`!`) on the end of the dynamic finders to get them to raise an `ActiveRecord::RecordNotFound` error if they do not return any records, like `Client.find_by_name!("Ryan")`
@@ -1352,6 +1347,11 @@ If you want to find both by name and locked, you can chain these finders togethe
Find or Build a New Object
--------------------------
+NOTE: Some dynamic finders have been deprecated in Rails 4.0 and will be
+removed in Rails 4.1. The best practice is to use Active Record scopes
+instead. You can find the deprecation gem at
+https://github.com/rails/activerecord-deprecated_finders
+
It's common that you need to find a record or create it if it doesn't exist. You can do that with the `find_or_create_by` and `find_or_create_by!` methods.
### `find_or_create_by`