aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2018-09-07 13:24:09 -0400
committerGitHub <noreply@github.com>2018-09-07 13:24:09 -0400
commitdd29fabebf1b702031213361b7757be5892cd59f (patch)
treea739422bfb194c910bbc91fd63e4d86877425239 /activemodel/lib
parent2a470d73a75ebf8cd7975e469bd82586d9234442 (diff)
parent8d2f3179e6f312b34a2bacf36bc74f9c24e751bd (diff)
downloadrails-dd29fabebf1b702031213361b7757be5892cd59f.tar.gz
rails-dd29fabebf1b702031213361b7757be5892cd59f.tar.bz2
rails-dd29fabebf1b702031213361b7757be5892cd59f.zip
Merge pull request #33615 from Larochelle/i18n_full_message_with_nested_attributes
`ActiveModel.full_message` interaction with `index_errors`
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/errors.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index edc30ee64d..af94d52d45 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -379,9 +379,11 @@ module ActiveModel
# * <tt>errors.format</tt>
def full_message(attribute, message)
return message if attribute == :base
+ attribute = attribute.to_s
if self.class.i18n_full_message && @base.class.respond_to?(:i18n_scope)
- parts = attribute.to_s.split(".")
+ attribute = attribute.remove(/\[\d\]/)
+ parts = attribute.split(".")
attribute_name = parts.pop
namespace = parts.join("/") unless parts.empty?
attributes_scope = "#{@base.class.i18n_scope}.errors.models"
@@ -410,8 +412,9 @@ module ActiveModel
defaults << :"errors.format"
defaults << "%{attribute} %{message}"
- attr_name = attribute.to_s.tr(".", "_").humanize
+ attr_name = attribute.tr(".", "_").humanize
attr_name = @base.class.human_attribute_name(attribute, default: attr_name)
+
I18n.t(defaults.shift,
default: defaults,
attribute: attr_name,