Flowdock
method

human_attribute_name

Importance_2
Ruby on Rails latest stable (v3.2.1) - 2 notes - Class: ActiveModel::Translation
human_attribute_name(attribute, options = {}) public

Transforms attribute names into a more human format, such as “First name” instead of “first_name”.

Person.human_attribute_name("first_name") # => "First name"

Specify options with additional translating options.

Show source
Register or log in to add new notes.
December 11, 2010 - (v3.0.0)
1 thank

I18n file to change an attribute's name

If you are using Active Record, use a locale file like the one below to change a model’s attribute’s human name.

en:
  activerecord:
    attributes:
      picture:
        explanation: Description

Without using the locale file:

ruby-1.9.2-p0 > Picture.human_attribute_name("explanation")
 => "Explanation" 

Using the locale file:

ruby-1.9.2-p0 > Picture.human_attribute_name("explanation")
 => "Description" 
June 29, 2011
0 thanks

Default values

For common attributes in several models, you can set a default human name like this:

de.yml

de:
  attributes:
    bez: Bezeichnung
    abk: Abkürzung