Rails generate invalid plural form

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

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

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

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

Is the error in the rails pluralized, or did I do something wrong?

+4
source share
1 answer

You can customize the rail finder. To do this, your application must have an initialization file: config/initializers/inflections.rb

Then you can add the β€œtrain” rails challenge to the new rule:

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

After restarting the server / console, a new pluralization should be in place.

+10
source

All Articles