Pluralizing Post-positive Adjectives in Rails

You know those adjectives that come after nouns? Well, sometimes you may want to pluralize them correctly in your Rails App. I might have been able to get by with “work_in_processes”, but “bill_of_materialsses” just wasn’t going to cut it.

Here’s the technique I used:

# Add new inflection rules using the following format:
ActiveSupport::Inflector.inflections do |inflect|
  inflect.irregular 'BillOfMaterials', 'BillsOfMaterials'
  inflect.irregular 'bill_of_materials', 'bills_of_materials'
 
  inflect.irregular 'WorkInProcess', 'WorksInProcess'
  inflect.irregular 'work_in_process', 'works_in_process'
end

If you have any improvements or suggestions please comment!

Now off to Burger King to order two Whoppers Jr.

One thought on “Pluralizing Post-positive Adjectives in Rails

  1. Pingback: Giving up on has_many_polymorphs bug after an hour

Leave a Reply

Your email address will not be published. Required fields are marked *