Created
July 23, 2009 16:33
-
-
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.
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 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