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
Fix creating payment method on the admin panel (#12786)
Damian Kaczmarczyk9bb7f3f35f77
diff --git a/admin/app/controllers/spree/admin/payment_methods_controller.rb b/admin/app/controllers/spree/admin/payment_methods_controller.rbindex 90f8c6b434..ad2631e02d 100644--- a/admin/app/controllers/spree/admin/payment_methods_controller.rb+++ b/admin/app/controllers/spree/admin/payment_methods_controller.rb@@ -14,10 +14,10 @@ module Spreeif params[:payment_method].present?payment_type = params[:payment_method].delete(:type)# Find the actual class from our allowed types rather than using constantize- payment_class = allowed_payment_types.find { |type| type.to_s == payment_type }+ payment_class = allowed_payment_types.find { |type| type == payment_type }- if payment_class- @object = payment_class.new+ if payment_class.present?+ @object = payment_class.constantize.newendendend@@ -45,7 +45,9 @@ module Spreeenddef allowed_payment_types- Rails.application.config.spree.payment_methods+ # We need to map to strings, otherwise some weird things happen with STI+ # where Rails can't find the ancestor class when we try to save the payment method.+ Rails.application.config.spree.payment_methods.map(&:to_s)enddef permitted_resource_params