views:

699

answers:

2

I have a model named "clothing" which I want to be the singlular (one piece of clothing). By default, rails says the plural is clothings. Right or wrong, I think it will be more readable if the plural is "clothes".

How do I override the plural naming convention? Can I do it right in the model so I don't have to do it over and over? How will this change how routes are handled (I am using restful architecture)?

Thanks.

+9  A: 

I'm no RoR expert, but did find a possible approach. From the referenced site you can add inflection rules, e.g.

# Add new inflection rules using the following format 
Inflector.inflections do |inflect|
  inflect.irregular 'clothing', 'clothes'
end

You will find these in your environment.rb file inside the config folder

Rich Seller
Actually, your custom inflections should reside in config/initializers/inflections.rb
BigCanOfTuna
+7  A: 

For rails 2.3.2 and maybe 2+, you need to do it a little different:

ActiveSupport::Inflector.inflections do |inflect|
    inflect.plural /^(ox)$/i, '\1\2en'
    inflect.singular /^(ox)en/i, '\1'

    inflect.irregular 'octopus', 'octopi'

    inflect.uncountable "equipment"
end
ChrisH