Flowdock
humanize(capitalize: true, keep_id_suffix: false) public

Capitalizes the first word, turns underscores into spaces, and (by default)strips a trailing ‘_id’ if present. Like titleize, this is meant for creating pretty output.

The capitalization of the first word can be turned off by setting the optional parameter capitalize to false. By default, this parameter is true.

The trailing ‘_id’ can be kept and capitalized by setting the optional parameter keep_id_suffix to true. By default, this parameter is false.

'employee_salary'.humanize                    # => "Employee salary"
'author_id'.humanize                          # => "Author"
'author_id'.humanize(capitalize: false)       # => "author"
'_id'.humanize                                # => "Id"
'author_id'.humanize(keep_id_suffix: true)    # => "Author Id"

See ActiveSupport::Inflector.humanize.

Show source
Register or log in to add new notes.