It is beyond anything you have ever experienced or imagined
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.
| Print article | This entry was posted by Daniel X Moore on July 20, 2009 at 10:22 am, and is filed under Programming. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |