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.

Start Writing Your Blog

Do you have a website? Do you have a blog? I’d totally love to read it.

The thing is though, that it takes a while for it to get good. I started with STRd6 almost two years ago, and it’s still not good. On the plus side though it adds incentive to keep cranking out the content. Each new article adds a new layer of better content to cover up the old.

So what are you waiting for? If you want a really high class blog then you’ll definitely need to start today. I bet you even have some ideas for blog posts saved up. You could easily write four in the first month.

So go ahead and do it already. You don’t need to worry about being better than the blogs that are already out there, just as good as they were when they started. I’m not even going to link back to my early posts… too embarrassing. And only 20 posts in 2008? You can totally beat that.

Add your new blog in the comments. I’ll check it out in a few years when it’s good.