mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Fix errors in PermittedAttributes::OrderCycle
This commit is contained in:
@@ -35,23 +35,8 @@ module PermittedAttributes
|
||||
:tag_list,
|
||||
tags: [:text],
|
||||
enterprise_fee_ids: [],
|
||||
variants: permitted_variant_ids
|
||||
variants: {}
|
||||
]
|
||||
end
|
||||
|
||||
# In rails 5 we will be able to permit random hash keys simply with :variants => {}
|
||||
# See https://github.com/rails/rails/commit/e86524c0c5a26ceec92895c830d1355ae47a7034
|
||||
#
|
||||
# Until then, we need to create an array of variant IDs in order to permit them
|
||||
def permitted_variant_ids
|
||||
variant_ids(@params[:order_cycle][:incoming_exchanges]) +
|
||||
variant_ids(@params[:order_cycle][:outgoing_exchanges])
|
||||
end
|
||||
|
||||
def variant_ids(exchange_params)
|
||||
return [] unless exchange_params
|
||||
|
||||
exchange_params.map { |exchange| exchange[:variants].map { |key, _value| key } }.flatten
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user