From 062c60344b0fb66999111f08d2d4865767077594 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Tue, 22 Feb 2011 22:18:14 +0900 Subject: [PATCH] fixes #21 ensure total_count returns a number Model.group.count does not return a Fixnum but an OrderdHash --- lib/kaminari/models/active_record_relation_methods.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/kaminari/models/active_record_relation_methods.rb b/lib/kaminari/models/active_record_relation_methods.rb index 362c12a..f8ceb5a 100644 --- a/lib/kaminari/models/active_record_relation_methods.rb +++ b/lib/kaminari/models/active_record_relation_methods.rb @@ -3,7 +3,9 @@ module Kaminari extend ActiveSupport::Concern module InstanceMethods def total_count #:nodoc: - except(:offset, :limit).count + c = except(:offset, :limit).count + # .group returns an OrderdHash that responds to #count + c.respond_to?(:count) ? c.count : c end end end