Skip to content
This repository

Fix bug where models weren't being pluralized correctly in page_entries_info #208

Closed
wants to merge 2 commits into from

3 participants

Ryan Hall Topper Bowers Mislav Marohnić
added some commits December 02, 2011
Fixed pluralization bug in page_entries_info e3b285a
bug fix: total_entries was returning the wrong value for DISTINCT ON …
…queries. This fix changes count to length when these queries come up.
c16fc52
Topper Bowers

+1

Mislav Marohnić
Owner

This fixes it only for the English language, so it defies the purpose of having i18n in the first place. Also, no tests.

Mislav Marohnić mislav closed this January 31, 2012
Topper Bowers

Is there a work around for now?

Mislav Marohnić
Owner

Not yet.

Christopher Meiklejohn cmeiklejohn referenced this pull request in rubygems/rubygems.org September 08, 2012
Closed

Incorrect pluralization in Search results page #456

anenadic anenadic referenced this pull request from a commit in BioVeL/biodiversitycatalogue July 01, 2013
anenadic Added entries for models in config/locales/en.yml as will_paginate ge…
…m does not pluralize models correctly in page_entries_info - see mislav/will_paginate#208.
86fc610
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Dec 02, 2011
Fixed pluralization bug in page_entries_info e3b285a
bug fix: total_entries was returning the wrong value for DISTINCT ON …
…queries. This fix changes count to length when these queries come up.
c16fc52
This page is out of date. Refresh to see the latest.
2  lib/will_paginate/active_record.rb
@@ -65,7 +65,7 @@ def count
65 65
           rel = self.except(*excluded)
66 66
           # TODO: hack. decide whether to keep
67 67
           rel = rel.apply_finder_options(@wp_count_options) if defined? @wp_count_options
68  
-          rel.count
  68
+          rel.to_sql =~ /DISTINCT .*ON/i ? rel.length : rel.count
69 69
         else
70 70
           super
71 71
         end
5  lib/will_paginate/view_helpers.rb
@@ -132,12 +132,13 @@ def page_entries_info(collection, options = {})
132 132
         end
133 133
       }
134 134
       model_name = will_paginate_translate defaults, :count => model_count
135  
-
  135
+      model_name = model_name.pluralize if collection.size > 1
  136
+      
136 137
       if collection.total_pages < 2
137 138
         i18n_key = :"page_entries_info.single_page#{html_key}"
138 139
         keys = [:"#{model_key}.#{i18n_key}", i18n_key]
139 140
 
140  
-        will_paginate_translate keys, :count => collection.size, :model => model_name do |_, opts|
  141
+        will_paginate_translate keys, :count => collection.length, :model => model_name do |_, opts|
141 142
           case opts[:count]
142 143
           when 0; "No #{opts[:model]} found"
143 144
           when 1; "Displaying #{b}1#{eb} #{opts[:model]}"
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.