mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Fix ForbiddenAttributesError on tag rules
This commit is contained in:
@@ -214,7 +214,8 @@ module Admin
|
||||
rule = @object.tag_rules.find_by(id: attrs.delete(:id)) ||
|
||||
attrs[:type].constantize.new(enterprise: @object)
|
||||
create_calculator_for(rule, attrs) if rule.type == "TagRule::DiscountOrder" && rule.calculator.nil?
|
||||
rule.update(attrs)
|
||||
|
||||
rule.update(attrs.permit(PermittedAttributes::TagRules.attributes))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
12
app/services/permitted_attributes/tag_rules.rb
Normal file
12
app/services/permitted_attributes/tag_rules.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module PermittedAttributes
|
||||
class TagRules
|
||||
def self.attributes
|
||||
[
|
||||
:id, :type, :preferred_customer_tags, :calculator_type,
|
||||
{ calculator_attributes: [:id, :preferred_flat_percent] }
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user