1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

default could be a symbol here so attribute.to_s.humanize should be the final option

This commit is contained in:
Santiago Pastorino 2010-12-05 12:57:45 -02:00
parent 20ba81e47d
commit 33b0a30fcc
2 changed files with 6 additions and 1 deletions

View file

@ -48,7 +48,8 @@ module ActiveModel
end
defaults << :"attributes.#{attribute}"
defaults << (options[:default] ? options.delete(:default) : attribute.to_s.humanize)
defaults << options.delete(:default) if options[:default]
defaults << attribute.to_s.humanize
options.reverse_merge! :count => 1, :default => defaults
I18n.translate(defaults.shift, options)

View file

@ -25,6 +25,10 @@ class ActiveModelI18nTests < ActiveModel::TestCase
assert_equal 'Name', Person.human_attribute_name('name')
end
def test_translated_model_attributes_using_default_option_as_symbol_and_falling_back_to_default
assert_equal 'Name', Person.human_attribute_name('name', :default => :default_name)
end
def test_translated_model_attributes_with_symbols
I18n.backend.store_translations 'en', :activemodel => {:attributes => {:person => {:name => 'person name attribute'} } }
assert_equal 'person name attribute', Person.human_attribute_name(:name)