Skip to content

Instantly share code, notes, and snippets.

@owainhunt
Created July 23, 2009 16:33
Show Gist options
  • Select an option

  • Save owainhunt/153181 to your computer and use it in GitHub Desktop.

Select an option

Save owainhunt/153181 to your computer and use it in GitHub Desktop.
Custom Inflector#titleize for Rails that ignores words which are already all-capitalized.
module ActiveSupport
module Inflector
def titleize(word)
words = word.split(' ')
processed_words = []
words.each do |aWord|
aWord = aWord.capitalize unless /^[A-Z]*$/.match(aWord)
processed_words << aWord
end
processed_words.join(" ")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment