Permalink
Browse files

Model#human_attribute_name now accept symbols [#3025 status:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent ba96125 commit 18b4ac6992bdd51b9c279c064b60692bb80235ba @arthurgeek arthurgeek committed with lifo Aug 9, 2009
Showing with 6 additions and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/base.rb
  2. +5 −0 activerecord/test/cases/i18n_test.rb
@@ -1364,7 +1364,7 @@ def human_attribute_name(attribute_key_name, options = {})
end
defaults << options[:default] if options[:default]
defaults.flatten!
- defaults << attribute_key_name.humanize
+ defaults << attribute_key_name.to_s.humanize
options[:count] ||= 1
I18n.translate(defaults.shift, options.merge(:default => defaults, :scope => [:activerecord, :attributes]))
end
@@ -12,6 +12,11 @@ def test_translated_model_attributes
I18n.backend.store_translations 'en', :activerecord => {:attributes => {:topic => {:title => 'topic title attribute'} } }
assert_equal 'topic title attribute', Topic.human_attribute_name('title')
end
+
+ def test_translated_model_attributes_with_symbols
+ I18n.backend.store_translations 'en', :activerecord => {:attributes => {:topic => {:title => 'topic title attribute'} } }
+ assert_equal 'topic title attribute', Topic.human_attribute_name(:title)
+ end
def test_translated_model_attributes_with_sti
I18n.backend.store_translations 'en', :activerecord => {:attributes => {:reply => {:title => 'reply title attribute'} } }

0 comments on commit 18b4ac6

Please sign in to comment.