String#pluralize does not handle plural
Closed this issue · 3 comments
balmoral commented
'objects'.pluralize
#=> 'objectss`
The issue is with implementation of Active::Inflector#apply_inflections.
Current code is:
rules.each do |rule, replacement|
changed = result.sub(rule, replacement)
unless changed == result
result = changed
break
end
end
but the rule for a word that is already plural will not change the word, so this test fails.
Suggestion for fix is:
rules.each do |rule, replacement|
if result =~ rule
result = result.sub(rule, replacement)
break
end
end
Need to add appropriate test too.
balmoral commented
PR sent. Newbie at PR'ing, so hope done right. Code should be fine, though tests don't cover inflections.