diff options
author | Justin French <justin@indent.com.au> | 2009-06-29 15:54:09 +0200 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2009-06-30 15:24:04 +1200 |
commit | 7d548f795d226f57278f8bdd36298c9552421053 (patch) | |
tree | 72ecb05cb089ef8ff7c9acd76a16bd7c2580290f /activerecord/lib | |
parent | 085db5e128ad4ad8fd042776722c78e194c6d0a4 (diff) | |
download | rails-7d548f795d226f57278f8bdd36298c9552421053.tar.gz rails-7d548f795d226f57278f8bdd36298c9552421053.tar.bz2 rails-7d548f795d226f57278f8bdd36298c9552421053.zip |
Changed ActiveRecord::Base.human_name to underscore the class name before it humanizes it
This gives you 'Post comment' rather than 'Postcomment' by default.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#2120 state:committed]
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index f1b7c323dc..ff5a836b52 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1404,14 +1404,14 @@ module ActiveRecord #:nodoc: end # Transform the modelname into a more humane format, using I18n. - # Defaults to the basic humanize method. + # By default, it will underscore then humanize the class name (BlogPost.human_name #=> "Blog post"). # Default scope of the translation is activerecord.models # Specify +options+ with additional translating options. def human_name(options = {}) defaults = self_and_descendants_from_active_record.map do |klass| :"#{klass.name.underscore}" - end - defaults << self.name.humanize + end + defaults << self.name.underscore.humanize I18n.translate(defaults.shift, {:scope => [:activerecord, :models], :count => 1, :default => defaults}.merge(options)) end |