user1938765
user1938765

Reputation: 41

Rails generate wrong pluralize form

I use Ruby 1.9.3 and Rails 3.2.9, when I do the following in a rails console:

1.9.3p125 :003 > "foot".pluralize => "foots" # shouldn't it be "feet"?

1.9.3p125 :004 > "tooth".pluralize => "tooths" # shouldn't it be "teeth"?

1.9.3p125 :009 > "goose".pluralize => "gooses" # shouldn't it be "geese"?

is that a bug in rails pluralize or I did something wrong?

Upvotes: 4

Views: 1167

Answers (1)

Yves Senn
Yves Senn

Reputation: 1996

You can configure the rails inflector. There should be an initializer file in your application to do so: config/initializers/inflections.rb

You can then add a call to "teach" rails the new rule:

ActiveSupport::Inflector.inflections do |inflect|
 inflect.irregular 'tooth', 'teeth'
end

After you restart the server/console the new pluralization should be in place.

Upvotes: 10

Related Questions