titleize a hyphenated name

You could also get the desired result by splitting up your string and titleizing the sections separately:

"mary-louise o'donnell".split('-').map(&:titleize).join('-')

Check Titelize implementation and from it you can get:

"mary-joe spencer-moore".humanize.gsub(/\b('?[a-z])/) { $1.capitalize }

will give you => "Mary-Joe Spencer-Moore"

and you can write a function for it in string class, Add to intalizers:

class String
  def my_titleize
    humanize.gsub(/\b('?[a-z])/) { $1.capitalize }
  end
end

and then from your code:

"mary-joe spencer-moore".my_titleize