module ActiveSupport::Inflector
def titleize(word, keep_id_suffix: false)
titleize('raiders_of_the_lost_ark') # => "Raiders Of The Lost Ark"
titleize('TheManWithoutAPast') # => "The Man Without A Past"
titleize('x-men: the last stand') # => "X Men: The Last Stand"
titleize('man from the boondocks') # => "Man From The Boondocks"
By default, this parameter is false.
optional parameter +keep_id_suffix+ to true.
The trailing '_id','Id'.. can be kept and capitalized by setting the
output. It is not used in the Rails internals.
create a nicer looking title. +titleize+ is meant for creating pretty
Capitalizes all the words and replaces some characters in the string to
def titleize(word, keep_id_suffix: false) humanize(underscore(word), keep_id_suffix: keep_id_suffix).gsub(/\b(?<!\w['’`()])[a-z]/) do |match| match.capitalize end end