aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-01-24 22:14:32 +0000
committerJon Leighton <j@jonathanleighton.com>2011-01-30 11:58:07 +0000
commit1a4bbaf106f09c8a67c7e4da109a46449c06374f (patch)
tree6fe35c77e30c9d4b5b909ff34042e311e8eea345
parent1e7cf6c7e9aede02e417885847346c225d309302 (diff)
downloadrails-1a4bbaf106f09c8a67c7e4da109a46449c06374f.tar.gz
rails-1a4bbaf106f09c8a67c7e4da109a46449c06374f.tar.bz2
rails-1a4bbaf106f09c8a67c7e4da109a46449c06374f.zip
Use scoped.first and scoped.last instead of find(:first, ...) and find(:last, ...)
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index 0ab2b4fb9d..2b0ab32f34 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -39,7 +39,7 @@ module ActiveRecord
# Fetches the first one using SQL if possible.
def first(*args)
if fetch_first_or_last_using_find?(args)
- find(:first, *args)
+ scoped.first(*args)
else
load_target unless loaded?
args.shift if args.first.kind_of?(Hash) && args.first.empty?
@@ -50,7 +50,7 @@ module ActiveRecord
# Fetches the last one using SQL if possible.
def last(*args)
if fetch_first_or_last_using_find?(args)
- find(:last, *args)
+ scoped.last(*args)
else
load_target unless loaded?
@target.last(*args)