From c198c5baca0dd64df02049852cab50cf221af946 Mon Sep 17 00:00:00 2001 From: Flavio Auciello Date: Fri, 9 Apr 2021 09:04:24 +0200 Subject: [PATCH] Fix deprecation warning related to Rails 6.2 > You are passing a block expecting two parameters, > so the old hash behavior is simulated. As this is deprecated, > this will result in an ArgumentError in Rails 6.2. > DEPRECATION WARNING: Enumerating ActiveModel::Errors as a hash has been deprecated. > In Rails 6.1, `errors` is an array of Error objects, > therefore it should be accessed by a block with a single block > parameter like this: > > person.errors.each do |error| > attribute = error.attribute > message = error.message > end --- app/models/solidus_paypal_braintree/transaction.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/solidus_paypal_braintree/transaction.rb b/app/models/solidus_paypal_braintree/transaction.rb index 1a42532a..cb0d7f49 100644 --- a/app/models/solidus_paypal_braintree/transaction.rb +++ b/app/models/solidus_paypal_braintree/transaction.rb @@ -18,8 +18,8 @@ class Transaction errors.add(:payment_method, 'Must be braintree') end if address && !address.valid? - address.errors.each do |field, error| - errors.add(:address, "#{field} #{error}") + address.errors.each do |error| + errors.add(:address, "#{error.attribute} #{error.message}") end end end