lib/adaptive_alias/patches/base.rb in adaptive_alias-1.1.0 vs lib/adaptive_alias/patches/base.rb in adaptive_alias-1.1.1

- old
+ new

@@ -61,12 +61,15 @@ @fix_missing_attribute = proc do |error_klass, error| next false if not patch.removable next false if patch.removed next false if klass.table_name != error_klass.table_name - next false if not expected_attribute_err_msgs.include?(error.message) + # Error highlight behavior in Ruby 3.1 pollutes the error message + error_msg = error.respond_to?(:original_message) ? error.original_message : error.message + next false if not expected_attribute_err_msgs.include?(error_msg) + patch.remove! next true end fix_arel_attributes = proc do |attr| @@ -86,28 +89,23 @@ @fix_association = proc do |relation, reflection, model, error| next false if not patch.removable next false if patch.removed - ambiguous = expected_ambiguous_association_err_msgs.include?(error.message) + # Error highlight behavior in Ruby 3.1 pollutes the error message + error_msg = error.respond_to?(:original_message) ? error.original_message : error.message + ambiguous = expected_ambiguous_association_err_msgs.include?(error_msg) if ambiguous next false if relation and klass.table_name != relation.klass.table_name next false if reflection and klass.table_name != reflection.klass.table_name next false if model and klass.table_name != model.class.table_name next false if !relation and !reflection and !model end - next false if not expected_association_err_msgs.include?(error.message) and not ambiguous + next false if not expected_association_err_msgs.include?(error_msg) and not ambiguous patch.remove! - - if model - attributes = model.instance_variable_get(:@attributes).instance_variable_get(:@attributes) - attributes.transform_keys! do |key| - key == current_column.to_s ? alias_column.to_s : key - end - end if relation relation.reset # reset @arel joins = relation.arel.source.right # @ctx.source.right << create_join(relation, nil, klass)