aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_record_querying.md
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2013-05-01 16:24:13 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2013-05-01 16:24:13 +0530
commit7ead1d81431b2c2c0366347b7bfdf9a329b6f934 (patch)
tree9a6a18fbb185cf2dfa48016dd32c787fe352752e /guides/source/active_record_querying.md
parent78db16d440c610edeb8b2bb37233a5991caf4a29 (diff)
parent8476932aacbc45ce38b007cca0bb3f12e741f709 (diff)
downloadrails-7ead1d81431b2c2c0366347b7bfdf9a329b6f934.tar.gz
rails-7ead1d81431b2c2c0366347b7bfdf9a329b6f934.tar.bz2
rails-7ead1d81431b2c2c0366347b7bfdf9a329b6f934.zip
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'guides/source/active_record_querying.md')
-rw-r--r--guides/source/active_record_querying.md7
1 files changed, 6 insertions, 1 deletions
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index 2589accadd..80eec428c1 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -707,7 +707,7 @@ Post.order('id DESC').limit(20).unscope(:order, :limit) = Post.all
You can additionally unscope specific where clauses. For example:
```ruby
-Post.where(:id => 10).limit(1).unscope(:where => :id, :limit).order('id DESC') = Post.order('id DESC')
+Post.where(:id => 10).limit(1).unscope(where: :id, :limit).order('id DESC') = Post.order('id DESC')
```
### `only`
@@ -1301,6 +1301,11 @@ 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")`