Skip to content

Commit

Permalink
Remove wrong definition of :option_values_attributes for variants
Browse files Browse the repository at this point in the history
Having `:option_values_attributes` declared as a plain Symbol has no
effect. Rails requires that nested attributes are explicitly declared
[1].

Variants already support `:option_value_ids` array [2] which cover the
most common use case (adding option values to an already created
variant), so there's no need to provide such a nested hierarchy.

1 - https://api.rubyonrails.org/classes/ActionController/StrongParameters.html
2 - https://github.com/solidusio/solidus/blob/07c88ddd1603699939ac0343965fa88dc2e1851a/core/lib/spree/permitted_attributes.rb#L135
  • Loading branch information
waiting-for-dev committed Jun 8, 2022
1 parent 4253707 commit 3b30854
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/lib/spree/permitted_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ module PermittedAttributes
@@variant_attributes = [
:name, :presentation, :cost_price, :lock_version,
:position, :track_inventory,
:product_id, :product, :option_values_attributes, :price,
:product_id, :product, :price,
:weight, :height, :width, :depth, :sku, :cost_currency, option_value_ids: [], options: [:name, :value]
]

Expand Down

0 comments on commit 3b30854

Please sign in to comment.