Method: Rea::ActiveRecordExt::ClassMethods#naming
- Defined in:
- lib/rea/active_record_ext.rb
#naming ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rea/active_record_ext.rb', line 37 def naming define_method :display_name do if self.respond_to? :name @display_name ||= proc do default = name.humanize subkey = case when self.respond_to?(:classification) "#{self.classification.try(:name)}.#{self.name}" else "#{self.name}" end key = "#{self.class.name.underscore}.names.#{subkey}" I18n.t(key,:default=>default) end.call end end end |