Handle strong params in variant_overrides_controller

We use a simpler way to permit on array within params here and change products_controller to the same style
This commit is contained in:
Luis Ramos
2020-02-23 16:11:42 +00:00
parent c110f4832d
commit 5b37e89738
2 changed files with 8 additions and 2 deletions

View File

@@ -68,7 +68,7 @@ module Admin
end
def load_collection
collection_hash = Hash[params[:variant_overrides].each_with_index.map { |vo, i| [i, vo] }]
collection_hash = Hash[variant_overrides_params.each_with_index.map { |vo, i| [i, vo] }]
@vo_set = VariantOverrideSet.new @variant_overrides, collection_attributes: collection_hash
end
@@ -92,5 +92,11 @@ module Admin
full_messages.each { |fm| errors.add(:base, fm) }
errors
end
def variant_overrides_params
params.require(:variant_overrides).map do |variant_override|
variant_override.permit(:id, :price, :count_on_hand, :sku, :on_demand)
end
end
end
end

View File

@@ -166,7 +166,7 @@ module Spree
def products_params
params.require(:products).map do |product|
ActionController::Parameters.new(product.to_hash).permit(:id, :name)
product.permit(:id, :name)
end
end