Skip to content

Commit

Permalink
Fixed count method to handle result from grouped relations.
Browse files Browse the repository at this point in the history
  • Loading branch information
budu committed Dec 3, 2011
1 parent d56a843 commit 8b84636
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/will_paginate/active_record.rb
Expand Up @@ -65,7 +65,9 @@ def count
rel = self.except(*excluded) rel = self.except(*excluded)
# TODO: hack. decide whether to keep # TODO: hack. decide whether to keep
rel = rel.apply_finder_options(@wp_count_options) if defined? @wp_count_options 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 else
super super
end end
Expand Down

0 comments on commit 8b84636

Please sign in to comment.