aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2013-01-02 04:42:47 +0900
committerAkira Matsuda <ronnie@dio.jp>2013-01-02 04:47:29 +0900
commit44717a9d548c95c7b01e7e0dce061257b3a93646 (patch)
tree89d31644f3eb7571d299524f432bac4e469e1042
parentad8275396ae6d76a6556e0f42d91e0a6dc42f4c8 (diff)
downloadrails-44717a9d548c95c7b01e7e0dce061257b3a93646.tar.gz
rails-44717a9d548c95c7b01e7e0dce061257b3a93646.tar.bz2
rails-44717a9d548c95c7b01e7e0dce061257b3a93646.zip
find_last_by is deprecated in AR 4
-rw-r--r--activerecord/lib/active_record/base.rb7
-rw-r--r--guides/source/active_record_querying.md2
2 files changed, 3 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 8285261e3e..3d374fe9b4 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -162,9 +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 <tt>find_by_</tt>, or <tt>find_last_by_</tt> and thus produces finders
- # like <tt>Person.find_by_user_name</tt>, and # <tt>Payment.find_by_transaction_id</tt>. Instead of writing
- # <tt>Person.where(user_name: user_name).first</tt>, you just do <tt>Person.find_by_user_name(user_name)</tt>.
+ # to <tt>find_by_</tt> # like <tt>Person.find_by_user_name</tt>.
+ # Instead of writing # <tt>Person.where(user_name: user_name).first</tt>, you just do
+ # <tt>Person.find_by_user_name(user_name)</tt>.
#
# It's possible to add an exclamation point (!) on the end of the dynamic finders to get them to raise an
# <tt>ActiveRecord::RecordNotFound</tt> error if they do not return any records,
@@ -178,7 +178,6 @@ module ActiveRecord #:nodoc:
# It's even possible to call these dynamic finder methods on relations and named scopes.
#
# 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.
# This dynamic finder is called with <tt>find_or_create_by_</tt> and will return the object if
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index 618dd2652b..62d6294ae5 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -1230,8 +1230,6 @@ 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` 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.
-
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")`
If you want to find both by name and locked, you can chain these finders together by simply typing "`and`" between the fields. For example, `Client.find_by_first_name_and_locked("Ryan", true)`.