public Method

Inflector.titleize(word)

Capitalizes all the words and replaces some characters in the string to create a nicer looking title. Titleize is meant for creating pretty output. It is not used in the Rails internals.

titleize is also aliased as as titlecase

Examples

"man from the boondocks".titleize #=> "Man From The Boondocks"
"x-men: the last stand".titleize #=> "X Men: The Last Stand"

Source Code

# File active_support/inflector.rb, line 164
def titleize(word)
  humanize(underscore(word)).gsub(/\b('?[a-z])/) { $1.capitalize }
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.