From a3259b01e58c7fa36f15f6bea8cdd7c26459f01f Mon Sep 17 00:00:00 2001 From: Rolf Bjaanes Date: Thu, 8 Apr 2010 21:55:51 +0200 Subject: [PATCH] Changed the way inflections for uncountables work for 'funky jeans' --- activesupport/lib/active_support/inflections.rb | 2 +- activesupport/lib/active_support/inflector.rb | 2 +- activesupport/test/inflector_test_cases.rb | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/activesupport/lib/active_support/inflections.rb b/activesupport/lib/active_support/inflections.rb index 8fb3fa9..e7b5387 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.rb b/activesupport/lib/active_support/inflector.rb index 5a3df58..f7c352b 100644 --- a/activesupport/lib/active_support/inflector.rb +++ b/activesupport/lib/active_support/inflector.rb @@ -158,7 +158,7 @@ module ActiveSupport 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 6908291..ecaa359 100644 --- a/activesupport/test/inflector_test_cases.rb +++ b/activesupport/test/inflector_test_cases.rb @@ -12,7 +12,9 @@ module InflectorTestCases "stack" => "stacks", "wish" => "wishes", "fish" => "fish", - + "jeans" => "jeans", + "funky jeans" => "funky jeans", + "category" => "categories", "query" => "queries", "ability" => "abilities", -- 1.7.0.4