mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user