From 6f8ade52eb38bfc351da0e289d5512919b4bfc30 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 27 Mar 2021 14:22:24 +0000 Subject: [PATCH] Persist last_ip_address when loading current_order Leaving the object with unpersisted changes breaks order locking with this error (in various places): RuntimeError: Locking a record with unpersisted changes is not supported. Use `save` to persist the changes, or `reload` to discard them explicitly. --- lib/spree/core/controller_helpers/order.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/spree/core/controller_helpers/order.rb b/lib/spree/core/controller_helpers/order.rb index d3f093cfd2..e0f7423613 100644 --- a/lib/spree/core/controller_helpers/order.rb +++ b/lib/spree/core/controller_helpers/order.rb @@ -52,7 +52,7 @@ module Spree return unless @current_order - @current_order.last_ip_address = ip_address + @current_order.update_columns(last_ip_address: ip_address) session[:order_id] = @current_order.id @current_order end