From 4eab983b955fe17cf02c6fe96cab1c8a309cd606 Mon Sep 17 00:00:00 2001 From: Rolf Bjaanes Date: Tue, 15 Dec 2009 18:36:28 +0100 Subject: [PATCH] Changed the way inflections for uncountables work for 'funky jeans' [#3576 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activesupport/lib/active_support/inflections.rb | 2 +- activesupport/lib/active_support/inflector/inflections.rb | 2 +- activesupport/test/inflector_test_cases.rb | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/inflections.rb b/activesupport/lib/active_support/inflections.rb index 8fb3fa9aa23ff..e7b5387ed7621 100644 --- a/activesupport/lib/active_support/inflections.rb +++ b/activesupport/lib/active_support/inflections.rb @@ -51,6 +51,6 @@ module ActiveSupport inflect.irregular('move', 'moves') inflect.irregular('cow', 'kine') - inflect.uncountable(%w(equipment information rice money species series fish sheep)) + inflect.uncountable(%w(equipment information rice money species series fish sheep jeans)) end end diff --git a/activesupport/lib/active_support/inflector/inflections.rb b/activesupport/lib/active_support/inflector/inflections.rb index 785e245ea41c3..3caf78bc7dfbb 100644 --- a/activesupport/lib/active_support/inflector/inflections.rb +++ b/activesupport/lib/active_support/inflector/inflections.rb @@ -148,7 +148,7 @@ def pluralize(word) def singularize(word) result = word.to_s.dup - if inflections.uncountables.include?(result.downcase) + if inflections.uncountables.any? { |inflection| result =~ /#{inflection}\Z/i } result else inflections.singulars.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } diff --git a/activesupport/test/inflector_test_cases.rb b/activesupport/test/inflector_test_cases.rb index 8dad9d815538d..29f87ac302efd 100644 --- a/activesupport/test/inflector_test_cases.rb +++ b/activesupport/test/inflector_test_cases.rb @@ -12,6 +12,8 @@ module InflectorTestCases "stack" => "stacks", "wish" => "wishes", "fish" => "fish", + "jeans" => "jeans", + "funky jeans" => "funky jeans", "category" => "categories", "query" => "queries",