public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Added Base.human_name method
iain (author)
Sat Aug 16 11:01:42 -0700 2008
svenfuchs (committer)
Wed Aug 20 08:39:43 -0700 2008
commit  ae8a35d8f6d5db6ae9a1877918d45c15d21e24fe
tree    9fc6857d9245e8d44cb95626f1c1899aacc4edef
parent  c379582064b4f345ecb6bab999e2f1c5685313a8
...
1249
1250
1251
 
 
 
 
 
 
 
 
 
 
 
 
 
1252
1253
1254
...
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
0
@@ -1249,6 +1249,19 @@ module ActiveRecord #:nodoc:
0
         options[:count] ||= 1
0
         I18n.translate(defaults.shift, options.merge(:default => defaults, :scope => [:activerecord, :attributes]))
0
       end
0
+
0
+      # Transform the modelname into a more humane format, using I18n.
0
+      # Defaults to the basic humanize method.
0
+      # Default scope of the translation is activerecord.models
0
+      # Specify +options+ with additional translating options.
0
+      def human_name(options = {})
0
+        defaults = self_and_descendents_from_active_record.map do |klass|
0
+          :"#{klass.name.underscore}"
0
+        end 
0
+        defaults << self.name.humanize
0
+        I18n.translate(defaults.shift, {:scope => [:activerecord, :models], :count => 1, :default => defaults}.merge(options))
0
+      end
0
+
0
       # True if this isn't a concrete subclass needing a STI type condition.
0
       def descends_from_active_record?
0
         if superclass.abstract_class?

Comments