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
There's not a nested attributes definition for option values in
variants. On top of that, having `:option_values_attributes` declared as
a plain Symbol would have 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 10, 2022
1 parent 4253707 commit c14578b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
4 changes: 0 additions & 4 deletions api/openapi/solidus-api.oas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7185,10 +7185,6 @@ components:
type: array
items:
type: integer
option_values_attributes:
type: array
items:
$ref: '#/components/schemas/option-value-input'
options:
type: object
description: '`Name` will be the name/presentation of the option type and `Value` will be the name/presentation of the option value. They will be created if not exist.'
Expand Down
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 c14578b

Please sign in to comment.