Making a rails inflection for possessive strings?

ruby-on-rails

Solution

I needed this too and so I made the implementation available on github and as a gem on rubygems so you can include it in your project pretty easy.

In rails 3 all you do is

gem "possessive" 

and you will have it.

Problem

I would like to create a method in additional to the default 'foo'.titlecase that will correctly add "possessiveness" to it. The string is a user's name (<- just did one right there! ) For example: "sam" is the user <%= user.titlecase.possessive + ' Profile' %> => #Sam's Profile It just needs to handle edge cases like: Steelers's Profile ( should be Steelers' Profile) Ross's Profile ( should be Ross' Profile )

Original source