From 719025f98e9566b37ffd677f20da94e9bf5fcd0f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Thu, 12 Jan 2023 17:12:03 +0100 Subject: [PATCH] Only set calculator if it's a new record (having an id) Unless we have a ActiveRecord::NotNullViolation ``` ActiveRecord::NotNullViolation: PG::NotNullViolation: ERROR: null value in column "calculable_id" of relation "spree_calculators" violates not-null constraint DETAIL: Failing row contains (9370, Calculator::None, null, Spree::ShippingMethod, 2023-01-12 15:09:44.381142, 2023-01-12 15:09:44.381142). # ------------------ # --- Caused by: --- # PG::NotNullViolation: # ERROR: null value in column "calculable_id" of relation "spree_calculators" violates not-null constraint # DETAIL: Failing row contains (9370, Calculator::None, null, Spree::ShippingMethod, 2023-01-12 15:09:44.381142, 2023-01-12 15:09:44.381142). ``` --- app/models/spree/shipping_method.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/spree/shipping_method.rb b/app/models/spree/shipping_method.rb index 3105c11127..b675e8fa1e 100644 --- a/app/models/spree/shipping_method.rb +++ b/app/models/spree/shipping_method.rb @@ -109,7 +109,7 @@ module Spree end def init - self.calculator ||= ::Calculator::None.new + self.calculator ||= ::Calculator::None.new if new_record? end private