Bring strong parameters code from spree to payment_methods_controller

This code comes from spree commit fbc2d150f6
This commit is contained in:
Luis Ramos
2020-02-22 17:41:45 +00:00
parent eccaaca907
commit 86d09ff21e

View File

@@ -15,7 +15,7 @@ module Spree
@payment_method = params[:payment_method].
delete(:type).
constantize.
new(params[:payment_method])
new(payment_method_params)
@object = @payment_method
invoke_callbacks(:create, :before)
@@ -40,8 +40,8 @@ module Spree
@payment_method = PaymentMethod.find(params[:id])
end
payment_method_params = params[ActiveModel::Naming.param_key(@payment_method)] || {}
attributes = params[:payment_method].merge(payment_method_params)
update_params = params[ActiveModel::Naming.param_key(@payment_method)] || {}
attributes = payment_method_params.merge(update_params)
attributes.each do |k, _v|
if k.include?("password") && attributes[k].blank?
attributes.delete(k)
@@ -100,6 +100,10 @@ module Spree
private
def payment_method_params
params.require(:payment_method).permit!
end
def force_environment
params[:payment_method][:environment] = Rails.env unless spree_current_user.admin?
end