Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Inflector irregular singularize rules #8671

Merged
merged 1 commit into from

2 participants

@xuanxu

The rules to singularize the singular in Inflector's irregular method were missing. Without them the new test case added fails.

This PR fix it adding the singular rules for irregular. And fixes #8605

@fxn
Owner

These seem like an overlook to me, if there is a reason to skip these singular rules please someone shout.

@fxn fxn merged commit 3f18f73 into from
@xuanxu xuanxu deleted the branch
@krhorst krhorst referenced this pull request in krhorst/active_admin_importable
Closed

uninitialized constant #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 1, 2013
  1. @xuanxu
This page is out of date. Refresh to see the latest.
View
3  activesupport/lib/active_support/inflector/inflections.rb
@@ -132,6 +132,7 @@ def irregular(singular, plural)
plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + plural[1..-1])
plural(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + plural[1..-1])
singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + singular[1..-1])
+ singular(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + singular[1..-1])
else
plural(Regexp.new("#{singular[0,1].upcase}(?i)#{singular[1..-1]}$"), plural[0,1].upcase + plural[1..-1])
plural(Regexp.new("#{singular[0,1].downcase}(?i)#{singular[1..-1]}$"), plural[0,1].downcase + plural[1..-1])
@@ -139,6 +140,8 @@ def irregular(singular, plural)
plural(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), plural[0,1].downcase + plural[1..-1])
singular(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), singular[0,1].upcase + singular[1..-1])
singular(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), singular[0,1].downcase + singular[1..-1])
+ singular(Regexp.new("#{singular[0,1].upcase}(?i)#{singular[1..-1]}$"), singular[0,1].upcase + singular[1..-1])
+ singular(Regexp.new("#{singular[0,1].downcase}(?i)#{singular[1..-1]}$"), singular[0,1].downcase + singular[1..-1])
end
end
View
1  activesupport/test/inflector_test_cases.rb
@@ -310,5 +310,6 @@ module InflectorTestCases
'move' => 'moves',
'cow' => 'kine',
'zombie' => 'zombies',
+ 'genus' => 'genera'
}
end
Something went wrong with that request. Please try again.