mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Model#human_attribute_name now accept symbols [#3025 status:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
parent
920ef4e6f3
commit
ce2422ceaf
2 changed files with 6 additions and 1 deletions
|
@ -1394,7 +1394,7 @@ module ActiveRecord #:nodoc:
|
|||
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
|
||||
|
|
|
@ -13,6 +13,11 @@ class ActiveRecordI18nTests < Test::Unit::TestCase
|
|||
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'} } }
|
||||
assert_equal 'reply title attribute', Reply.human_attribute_name('title')
|
||||
|
|
Loading…
Reference in a new issue