humanize

humanize(lower_case_and_underscored_word, options = {})
Instance Public methods

Capitalizes the first word, turns underscores into spaces, and 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.

humanize('employee_salary')              # => "Employee salary"
humanize('author_id')                    # => "Author"
humanize('author_id', capitalize: false) # => "author"
doc_ruby_on_rails
2015-06-20 00:00:00
Comments
Leave a Comment

Please login to continue.