@@ -11,8 +11,6 @@ class ProductsController < SolidusAdmin::BaseController
11
11
search_scope ( :in_stock ) { _1 . where ( id : Spree ::Variant . in_stock . distinct . select ( :product_id ) ) }
12
12
search_scope ( :out_of_stock ) { _1 . where . not ( id : Spree ::Variant . in_stock . distinct . select ( :product_id ) ) }
13
13
14
- before_action :split_params , only : [ :update ]
15
-
16
14
def index
17
15
products = apply_search_to (
18
16
Spree ::Product . includes ( :master , :variants ) ,
@@ -44,7 +42,7 @@ def show
44
42
def update
45
43
@product = Spree ::Product . friendly . find ( params [ :id ] )
46
44
47
- if @product . update ( params . require ( :product ) . permit! )
45
+ if @product . update ( product_params )
48
46
flash [ :success ] = t ( 'spree.successfully_updated' , resource : [
49
47
Spree ::Product . model_name . human ,
50
48
@product . name . inspect ,
@@ -101,13 +99,12 @@ def activate
101
99
redirect_to products_path , status : :see_other
102
100
end
103
101
104
- def split_params
105
- if params [ :product ] [ :taxon_ids ] . present?
106
- params [ :product ] [ :taxon_ids ] = params [ :product ] [ :taxon_ids ] . split ( ',' )
107
- end
108
- if params [ :product ] [ :option_type_ids ] . present?
109
- params [ :product ] [ :option_type_ids ] = params [ :product ] [ :option_type_ids ] . split ( ',' )
110
- end
102
+ private
103
+
104
+ def product_params
105
+ params . require ( :product ) . permit ( :name , :slug , :description , :meta_title , :meta_description , :meta_keywords , :gtin ,
106
+ :condition , :price , :cost_price , :cost_currency , :sku , :shipping_category_id , :tax_category_id ,
107
+ :available_on , :discontinue_on , :promotionable , option_type_ids : [ ] , taxon_ids : [ ] )
111
108
end
112
109
end
113
110
end
0 commit comments