aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-12-05 06:09:33 -0800
committerJosé Valim <jose.valim@gmail.com>2011-12-05 06:09:33 -0800
commit2985151000b9949474b8b575e25bf7ced387da02 (patch)
treee95b1014ed2d3420a03c093583d8ae411a2d55a0 /activemodel/lib/active_model
parentbe482bd6d6d83aad6c281925e3a1c776bfa5e7cd (diff)
parentdff19f7be2584d9eaa869de14a919aa70d029d92 (diff)
downloadrails-2985151000b9949474b8b575e25bf7ced387da02.tar.gz
rails-2985151000b9949474b8b575e25bf7ced387da02.tar.bz2
rails-2985151000b9949474b8b575e25bf7ced387da02.zip
Merge pull request #3859 from kuroda/human_attribute_name
Fix human_attribute_name to handle names with dots
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/translation.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/translation.rb b/activemodel/lib/active_model/translation.rb
index 6d64c81b5f..d776fe0ce6 100644
--- a/activemodel/lib/active_model/translation.rb
+++ b/activemodel/lib/active_model/translation.rb
@@ -43,8 +43,12 @@ module ActiveModel
#
# Specify +options+ with additional translating options.
def human_attribute_name(attribute, options = {})
- defaults = lookup_ancestors.map do |klass|
- :"#{self.i18n_scope}.attributes.#{klass.model_name.i18n_key}.#{attribute}"
+ defaults = []
+ lookup_ancestors.each do |klass|
+ if attribute.match(/\./)
+ defaults << :"#{self.i18n_scope}.attributes.#{klass.model_name.i18n_key}.#{attribute.gsub(/\./, '/')}"
+ end
+ defaults << :"#{self.i18n_scope}.attributes.#{klass.model_name.i18n_key}.#{attribute}"
end
defaults << :"attributes.#{attribute}"