Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 4993

Show
Ignore:
Timestamp:
09/04/06 19:23:07 (2 years ago)
Author:
david
Message:

Fixed TextHelper#pluralize to handle 1 as a string (closes #5905) [rails@bencurtis.com]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r4989 r4993  
    11*SVN* 
     2 
     3* Fixed TextHelper#pluralize to handle 1 as a string #5905 [rails@bencurtis.com] 
    24 
    35* Improved resolution of DateHelper#distance_of_time_in_words for better precision #5994 [Bob Silva] 
  • trunk/actionpack/lib/action_view/helpers/text_helper.rb

    r4916 r4993  
    6161      # Attempts to pluralize the +singular+ word unless +count+ is 1. See source for pluralization rules. 
    6262      def pluralize(count, singular, plural = nil) 
    63          "#{count} " + if count == 1 
     63         "#{count} " + if count == 1 || count == '1' 
    6464          singular 
    6565        elsif plural 
  • trunk/actionpack/test/template/text_helper_test.rb

    r4916 r4993  
    113113    assert_equal("1 count", pluralize(1, "count")) 
    114114    assert_equal("2 counts", pluralize(2, "count")) 
     115    assert_equal("1 count", pluralize('1', "count")) 
     116    assert_equal("2 counts", pluralize('2', "count")) 
     117    assert_equal("1,066 counts", pluralize('1,066', "count")) 
     118    assert_equal("1.25 counts", pluralize('1.25', "count")) 
    115119  end 
    116120