aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-01-17 19:53:42 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-01-17 19:53:42 +0000
commit1b38c5523ecff17d4d78181db0fad1a74567c776 (patch)
tree1671abfe3831d19a6894d065dd7e6e7aa3c270cd /activesupport/lib
parentecfe77f38d21779af96bc9b8f876c15620151d6a (diff)
downloadrails-1b38c5523ecff17d4d78181db0fad1a74567c776.tar.gz
rails-1b38c5523ecff17d4d78181db0fad1a74567c776.tar.bz2
rails-1b38c5523ecff17d4d78181db0fad1a74567c776.zip
Added Inflector.humanize to turn attribute names like employee_salary into "Employee salary". Used by automated error reporting in AR.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@449 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/inflector.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activesupport/lib/inflector.rb b/activesupport/lib/inflector.rb
index f84a45ea7f..6c8a60e6c4 100644
--- a/activesupport/lib/inflector.rb
+++ b/activesupport/lib/inflector.rb
@@ -27,6 +27,10 @@ module Inflector
camel_cased_word.to_s.gsub(/([A-Z]+)([A-Z])/,'\1_\2').gsub(/([a-z])([A-Z])/,'\1_\2').downcase
end
+ def humanize(lower_case_and_underscored_word)
+ lower_case_and_underscored_word.to_s.gsub(/_/, " ").capitalize
+ end
+
def demodulize(class_name_in_module)
class_name_in_module.to_s.gsub(/^.*::/, '')
end