chell
chell

Reputation: 7866

How to get accurate pluralization with Rails pluralization

I need very accurate pluralization for my application

I am currently using the Rails built in pluralization method.

I found a problem with the word 'foot'.

When I do:

"foot".pluralize(2)
=> "foots"

The correct pluralization should be feet.

How can I get more accurate results? I have looked for other gems and they all seem to make the same error.

Upvotes: 1

Views: 252

Answers (1)

Darpan Chhatravala
Darpan Chhatravala

Reputation: 520

you need to define below code inside your config/initializers/inflections.rb

ActiveSupport::Inflector.inflections(:en) do |inflect|
  inflect.irregular 'foot', 'feet'
end
  • there are some of plural are not define yet, so you need to define it inside inflections.

Upvotes: 3

Related Questions