diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 13424e621c..8285261e3e 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -162,12 +162,9 @@ module ActiveRecord #:nodoc: # # Dynamic attribute-based finders are a cleaner way of getting (and/or creating) objects # by simple queries without turning to SQL. They work by appending the name of an attribute - # to find_by_, find_last_by_, or find_all_by_ and thus produces finders - # like Person.find_by_user_name, Person.find_all_by_last_name, and - # Payment.find_by_transaction_id. Instead of writing + # to find_by_, or find_last_by_ and thus produces finders + # like Person.find_by_user_name, and # Payment.find_by_transaction_id. Instead of writing # Person.where(user_name: user_name).first, you just do Person.find_by_user_name(user_name). - # And instead of writing Person.where(last_name: last_name).all, you just do - # Person.find_all_by_last_name(last_name). # # It's possible to add 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, @@ -180,7 +177,7 @@ module ActiveRecord #:nodoc: # # It's even possible to call these dynamic finder methods on relations and named scopes. # - # Payment.order("created_on").find_all_by_amount(50) + # Payment.order("created_on").find_by_amount(50) # Payment.pending.find_last_by_amount(100) # # The same dynamic finder style can be used to create the object if it doesn't already exist. diff --git a/guides/source/active_record_callbacks.md b/guides/source/active_record_callbacks.md index 0a93f61f6d..d743badfe7 100644 --- a/guides/source/active_record_callbacks.md +++ b/guides/source/active_record_callbacks.md @@ -168,7 +168,6 @@ Additionally, the `after_find` callback is triggered by the following finder met * `all` * `first` * `find` -* `find_all_by_*` * `find_by_*` * `find_by_*!` * `find_by_sql` @@ -176,7 +175,7 @@ Additionally, the `after_find` callback is triggered by the following finder met The `after_initialize` callback is triggered every time a new object of the class is initialized. -NOTE: The `find_all_by_*`, `find_by_*` and `find_by_*!` methods are dynamic finders generated automatically for every attribute. Learn more about them at the [Dynamic finders section](active_record_querying.html#dynamic-finders) +NOTE: The `find_by_*` and `find_by_*!` methods are dynamic finders generated automatically for every attribute. Learn more about them at the [Dynamic finders section](active_record_querying.html#dynamic-finders) Skipping Callbacks ------------------ diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 24f98f68ca..618dd2652b 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -1228,7 +1228,7 @@ Client.unscoped { Dynamic 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` and `find_all_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 `find_all_by_locked` methods. +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 also use `find_last_by_*` methods which will find the last record matching your argument.