Quick Tip: Rails Singularization of -ess
Have you ever created a Ruby on Rails application dealing with businesses or addresses? I’d be hard pressed to find someone who hasn’t.
Strangely, though, Rails does not have an inflection that deals with the singularization of these words correctly. From the command line, try singularizing the word “business”:
While this seems like a contrived situation, it’s actually not as hard to hit as you’d think (e.g., common code that needs to singularize the incoming argument). I saw this while using Acl9, a role-based authorization system for Rails…
Here’s a quick fix that you can add to your config/initializers/inflections.rb:
You can read more about how this won’t be fixed in this ticket.
More of my rantings
- Quick Tip: Rails Named Bind Variables
- Quick Tip: Override Rails Generated URLs
- Quick Tip: Cucumber Works-in-Progress
These might also interest you
- A Culture of Negativity (Brian Shaler)
- ReadPhoenix: Top Blog Posts of the Week #1 (Brian Shaler)
- Keep Configuration out of Your Rails Apps with YAML (RXGX)