Skip to content

Commit

Permalink
Model#human_attribute_name now accept symbols [#3025 status:resolved]
Browse files Browse the repository at this point in the history
Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
arthurgeek authored and lifo committed Aug 9, 2009
1 parent ba96125 commit 18b4ac6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/base.rb
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions activerecord/test/cases/i18n_test.rb
Expand Up @@ -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'} } }
Expand Down

0 comments on commit 18b4ac6

Please sign in to comment.