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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Autostrip whitespace from Product's names and Variant's SKUs (#11623)
Damian Legawiec9fbbb3fa6b42
diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rbindex 656b81ac1a..83f361afcf 100644--- a/core/app/models/spree/product.rb+++ b/core/app/models/spree/product.rb@@ -39,6 +39,7 @@ module Spreefriendly_id :slug_candidates, use: :historyacts_as_paranoid+ auto_strip_attributes :name# we need to have this callback before any dependent: :destroy associations# https://github.com/rails/rails/issues/3458diff --git a/core/app/models/spree/variant.rb b/core/app/models/spree/variant.rbindex 2d8323bbb6..48990bf221 100644--- a/core/app/models/spree/variant.rb+++ b/core/app/models/spree/variant.rb@@ -17,6 +17,8 @@ module Spreedelegate :name, :name=, :description, :slug, :available_on, :make_active_at, :shipping_category_id,:meta_description, :meta_keywords, :shipping_category, to: :product+ auto_strip_attributes :sku, nullify: false+# we need to have this callback before any dependent: :destroy associations# https://github.com/rails/rails/issues/3458before_destroy :ensure_not_in_complete_orders@@ -170,7 +172,7 @@ module Spreedef options=(options = {})options.each do |option|- skip if option[:name].blank? || option[:value].blank?+ next if option[:name].blank? || option[:value].blank?set_option_value(option[:name], option[:value])end