From d6890e9828ece5ecab8a068e2fa60311c236edb3 Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Thu, 26 Oct 2023 10:03:25 +0100 Subject: [PATCH] check key class before call Rails.cache.delete --- app/controllers/spree/admin/payment_methods_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/spree/admin/payment_methods_controller.rb b/app/controllers/spree/admin/payment_methods_controller.rb index 077cddbca8..6398f02f65 100644 --- a/app/controllers/spree/admin/payment_methods_controller.rb +++ b/app/controllers/spree/admin/payment_methods_controller.rb @@ -197,10 +197,16 @@ module Spree def clear_preference_cache @payment_method.calculator.preferences.each_key do |key| - Rails.cache.delete(@payment_method.calculator.preference_cache_key(key)) + delete_from_cache @payment_method.calculator.preference_cache_key(key) end end + def delete_from_cache(cache_key) + return unless cache_key.class.in? [String, Integer, Float, Symbol] + + Rails.cache.delete(cache_key) + end + def add_type_to_calculator_attributes(hash) hash["calculator_attributes"]["type"] = hash["calculator_type"] end