From 1c26a39f154ac9c38e5513c664656f91e0fe06d6 Mon Sep 17 00:00:00 2001 From: lulalala Date: Thu, 9 May 2024 23:45:29 +0800 Subject: [PATCH] Fix test It seems now attribute being base should always be part of the key --- .../lib/active_record/associations/nested_error.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/activerecord/lib/active_record/associations/nested_error.rb b/activerecord/lib/active_record/associations/nested_error.rb index 3bdca88765f7..794118dc2e1c 100644 --- a/activerecord/lib/active_record/associations/nested_error.rb +++ b/activerecord/lib/active_record/associations/nested_error.rb @@ -18,15 +18,11 @@ def initialize(association, inner_error) def compute_attribute(inner_error) association_name = association.reflection.name - attribute = - if index_errors_setting && index - "#{association_name}[#{index}]" - else - association_name - end - - attribute = :"#{attribute}.#{inner_error.attribute}" if inner_error.attribute != :base - attribute.to_sym + if index_errors_setting && index + "#{association_name}[#{index}].#{inner_error.attribute}".to_sym + else + "#{association_name}.#{inner_error.attribute}".to_sym + end end def index_errors_setting