From 1b38c5523ecff17d4d78181db0fad1a74567c776 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 17 Jan 2005 19:53:42 +0000 Subject: 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 --- activesupport/lib/inflector.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activesupport/lib') 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 -- cgit v1.2.3