Sha256: d2783d1889ef8d86d40ce0cfdfaa6a6fc7b921bb68e2e090a548bd505f1d7018
Contents?: true
Size: 644 Bytes
Versions: 3
Compression:
Stored size: 644 Bytes
Contents
module ActiveModel module Translation # CarDealer.sales_count -> s_('CarDealer|Sales count') -> 'Sales count' if no translation was found def human_attribute_name(attribute, *args) s_(gettext_translation_for_attribute_name(attribute)) end def gettext_translation_for_attribute_name(attribute) attribute = attribute.to_s if attribute.ends_with?('_id') humanize_class_name(attribute) else "#{self}|#{attribute.split('.').map! {|a| a.humanize }.join('|')}" end end def humanize_class_name(name=nil) name ||= self.to_s name.underscore.humanize end end end
Version data entries
3 entries across 3 versions & 1 rubygems