class method self.human_attribute_name

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

self.human_attribute_name(attribute_key_name, options = {})

Transforms attribute key names into a more humane format, such as “First name” instead of “first_name”. Example:

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

This used to be depricated in favor of humanize, but is now preferred, because it automatically uses the I18n module now. Specify options with additional translating options.

Parameters

attribute_key_name req
options opt = {}
Source
# File activerecord/lib/active_record/base.rb, line 1310
      def human_attribute_name(attribute_key_name, options = {})
        defaults = self_and_descendents_from_active_record.map do |klass|
          :"#{klass.name.underscore}.#{attribute_key_name}"
        end
        defaults << options[:default] if options[:default]
        defaults.flatten!
        defaults << attribute_key_name.humanize
        options[:count] ||= 1
        I18n.translate(defaults.shift, options.merge(:default => defaults, :scope => [:activerecord, :attributes]))
      end

Defined in activerecord/lib/active_record/base.rb line 1310 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Base

Type at least 2 characters to search.

↑↓ navigate · open · esc close