Module: ActiveModel::Translation

Defined in:
lib/humpyard/active_model/translation.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#human_attribute_name_with_namespaces(attribute, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/humpyard/active_model/translation.rb', line 5

def human_attribute_name_with_namespaces(attribute, options = {})    
  # Namespace patch
  defaults = []
  lookup_ancestors.each do |klass|
    name = klass.model_name.underscore.split('/')
    while name.size > 0
      defaults << :"#{self.i18n_scope}.attributes.#{name * '.'}.#{attribute}"
      name.pop
    end
  end

  # Rails orig
  defaults << :"attributes.#{attribute}"
  defaults << options.delete(:default) if options[:default]
  defaults << attribute.to_s.humanize

  options.reverse_merge! :count => 1, :default => defaults
  I18n.translate(defaults.shift, options)
end