提交 ce2422ce 编写于 作者: A Arthur Zapparoli 提交者: Pratik Naik

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

Signed-off-by: NJosé Valim <jose.valim@gmail.com>
上级 920ef4e6
......@@ -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'} } }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册