aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-05-08 23:43:34 +0100
committerJon Leighton <j@jonathanleighton.com>2011-05-08 23:43:34 +0100
commit72a489345280964b4e4350fa6104658cd4e8da84 (patch)
tree8351dd83c3f7254c6ff0ed9f2c7a3eac832d2323 /activerecord/lib/active_record/relation
parent8f10ccd311e0813114c1aca266c82651ae77f6ca (diff)
parent92c10760d7f5e1d308e492d5fd3d551df41bfabb (diff)
downloadrails-72a489345280964b4e4350fa6104658cd4e8da84.tar.gz
rails-72a489345280964b4e4350fa6104658cd4e8da84.tar.bz2
rails-72a489345280964b4e4350fa6104658cd4e8da84.zip
Merge pull request #451 from baroquebobcat/fixing_last_for_issue_371
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index 57c9921ea8..32d1cff6c3 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -375,7 +375,12 @@ module ActiveRecord
if loaded?
@records.last
else
- @last ||= reverse_order.limit(1).to_a[0]
+ @last ||=
+ if offset_value || limit_value
+ to_a.last
+ else
+ reverse_order.limit(1).to_a[0]
+ end
end
end