Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Rename set_store to ensure_current_store

Damian Legawiec9fa15355559d
diff --git a/backend/app/controllers/spree/admin/products_controller.rb b/backend/app/controllers/spree/admin/products_controller.rb
index cd77f9f7a7..470b3d9e43 100644
--- a/backend/app/controllers/spree/admin/products_controller.rb
+++ b/backend/app/controllers/spree/admin/products_controller.rb
@@ -28,6 +28,7 @@ module Spree
end
invoke_callbacks(:update, :before)
if @object.update(permitted_resource_params)
+ ensure_current_store
invoke_callbacks(:update, :after)
flash[:success] = flash_message_for(@object, :successfully_updated)
respond_with(@object) do |format|
diff --git a/backend/app/controllers/spree/admin/resource_controller.rb b/backend/app/controllers/spree/admin/resource_controller.rb
index 199691165e..3e1678801e 100644
--- a/backend/app/controllers/spree/admin/resource_controller.rb
+++ b/backend/app/controllers/spree/admin/resource_controller.rb
@@ -3,7 +3,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
helper_method :new_object_url, :edit_object_url, :object_url, :collection_url
before_action :load_resource, except: :update_positions
- before_action :set_currency, :set_store, only: [:new, :create]
+ before_action :set_currency, :ensure_current_store, only: [:new, :create]
rescue_from ActiveRecord::RecordNotFound, with: :resource_not_found
respond_to :html
@@ -26,6 +26,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
def update
invoke_callbacks(:update, :before)
if @object.update(permitted_resource_params)
+ ensure_current_store
invoke_callbacks(:update, :after)
respond_with(@object) do |format|
format.html do
@@ -202,7 +203,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
@object.cost_currency = current_currency if model_class.method_defined?(:cost_currency=)
end
- def set_store
+ def ensure_current_store
return if @object.nil?
if @object.has_attribute?(:store_id)