Sha256: 27f706c8b7a10f40b71cf58530abecd2c9113294a1398d62433d805a5c824c41

Contents?: true

Size: 817 Bytes

Versions: 1

Compression:

Stored size: 817 Bytes

Contents

require 'active_model/translation'

module ActiveModel #:nodoc:
  module Translation #:nodoc:
    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
    alias_method_chain :human_attribute_name, :namespaces
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
humpyard-0.0.1 lib/humpyard/active_model/translation.rb