Created
March 9, 2012 16:21
-
-
Save nacengineer/2007339 to your computer and use it in GitHub Desktop.
Monkeypatch to Rails titleize
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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