Permalink
Browse files

Fixed count method to handle result from grouped relations.

  • Loading branch information...
1 parent d56a843 commit 8b8463686f6f679a9b34426a391a0417948ae6bc @budu committed Dec 3, 2011
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/will_paginate/active_record.rb
@@ -65,7 +65,9 @@ def count
rel = self.except(*excluded)
# TODO: hack. decide whether to keep
rel = rel.apply_finder_options(@wp_count_options) if defined? @wp_count_options
- rel.count
+ result = rel.count
+ # TODO: hack. handle count result returned by grouped relation
+ result.is_a?(Hash) ? result.values.reduce(&:+) : result
else
super
end

0 comments on commit 8b84636

Please sign in to comment.