From ca38024f39213d11d093e520be186eaec1658d76 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Thu, 21 Apr 2011 22:48:58 +0900 Subject: [PATCH] don't load all records when counting without limiting (thanks to @ankane) this fixes serious performance regression introduced in 0.11.0. --- lib/kaminari/models/active_record_relation_methods.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/kaminari/models/active_record_relation_methods.rb b/lib/kaminari/models/active_record_relation_methods.rb index 877c41c..2d57bdd 100644 --- a/lib/kaminari/models/active_record_relation_methods.rb +++ b/lib/kaminari/models/active_record_relation_methods.rb @@ -3,9 +3,10 @@ module Kaminari extend ActiveSupport::Concern module InstanceMethods # a workaround for AR 3.0.x that returns 0 for #count when page > 1 + # if +limit_value+ is specified, load all the records and count them if Rails.version < '3.1' def count #:nodoc: - limit_value == 0 ? 0 : length + limit_value ? length : super end end