Skip to content

Fix bug where page_entries_info does render correctly with a group by clause #207

Closed
wants to merge 2 commits into from
View
8 lib/will_paginate/view_helpers.rb
@@ -136,8 +136,12 @@ def page_entries_info(collection, options = {})
if collection.total_pages < 2
i18n_key = :"page_entries_info.single_page#{html_key}"
keys = [:"#{model_key}.#{i18n_key}", i18n_key]
-
- will_paginate_translate keys, :count => collection.size, :model => model_name do |_, opts|
+
+ count = collection.size
+
+ # If a group clause was used, count is returned as hash of :group => :count
+ count = count.length if count.is_a? Hash
+ will_paginate_translate keys, :count => count, :model => model_name do |_, opts|
case opts[:count]
when 0; "No #{opts[:model]} found"
when 1; "Displaying #{b}1#{eb} #{opts[:model]}"
Something went wrong with that request. Please try again.