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

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Arthur Zapparoli 2009-08-09 14:42:38 -03:00 committed by Pratik Naik
parent 920ef4e6f3
commit ce2422ceaf
2 changed files with 6 additions and 1 deletions

@ -1394,7 +1394,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'} } }