From c61544c7818f109c132fcad9db73d43216417535 Mon Sep 17 00:00:00 2001 From: claudiob Date: Wed, 6 Nov 2013 12:57:21 -0800 Subject: Add +capitalize+ option to Inflector.humanize So strings can be humanized without being capitalized: 'employee_salary'.humanize # => "Employee salary" 'employee_salary'.humanize(capitalize: false) # => "employee salary" --- guides/source/active_support_core_extensions.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'guides') diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index 0370e40012..b72ebd63ee 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -1772,6 +1772,12 @@ The method `humanize` gives you a sensible name for display out of an attribute "comments_count".humanize # => "Comments count" ``` +The capitalization of the first word can be turned off by setting the optional parameter `capitalize` to false: + +```ruby +"author_id".humanize(capitalize: false) # => "author" +``` + The helper method `full_messages` uses `humanize` as a fallback to include attribute names: ```ruby -- cgit v1.2.3