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:53:04 -0700 2008
commit  81e14fada17817dd16a69933bf688969308c22da
tree    1171f4049bf1a01b356ce08d2aee08263bee55d7
parent  a2d67403ac84fe6fef659ac3b17d430f141cda41
...
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