Skip to content

Instantly share code, notes, and snippets.

@nacengineer
Created March 9, 2012 16:21
Show Gist options
  • Save nacengineer/2007339 to your computer and use it in GitHub Desktop.
Save nacengineer/2007339 to your computer and use it in GitHub Desktop.
Monkeypatch to Rails titleize
module Monkeys
# Here there be monkeys! This is for english langauge.
# essentially the regex doesn't titleize 1, 2, & 3 letter words
# needs improvement IMO. Maybe an array of black list words.
# eg. of an a the
module ActiveSupport::Inflector
def titleize(word)
humanize(underscore(word)).gsub(/\b('?[a-z]{3})/) { $1.capitalize }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment