From f038bf82cb0edd83e2c7fc4461836376dea74e11 Mon Sep 17 00:00:00 2001 From: Alexander Podgorbunskiy Date: Wed, 24 Aug 2022 22:47:08 +0400 Subject: [PATCH] Fix represneted attribtues' errors moving --- lib/active_data/model/representation.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/active_data/model/representation.rb b/lib/active_data/model/representation.rb index 974f020..c463866 100644 --- a/lib/active_data/model/representation.rb +++ b/lib/active_data/model/representation.rb @@ -74,12 +74,8 @@ def emerge_represented_attributes_errors! if ActiveModel.version >= Gem::Version.new('6.1.0') def move_errors(from, to) - errors.each do |error| - next unless error.attribute == from - - errors.add(to, error.type, message: error.message) - errors.delete(error.attribute, error.type) - end + errors.where(from).each { |error| errors.add(to, error.type, **error.options) } + errors.delete(from) end else # up to 6.0.x def move_errors(from, to)