Commit 2ef915a2 by ivan Lan

Fit the controllers to the new change

parent 757e76d6
...@@ -30,11 +30,11 @@ module Shotengai ...@@ -30,11 +30,11 @@ module Shotengai
private private
def resource_params def resource_params
remark_input = params.require(resource_key).fetch(:remark_input, nil)&.map(&:permit!) remark_value = params.require(resource_key).fetch(:remark_value, nil)&.map(&:permit!)
info_input = params.require(resource_key).fetch(:info_input, nil)&.map(&:permit!) info_value = params.require(resource_key).fetch(:info_value, nil)&.map(&:permit!)
params.require(resource_key).permit( params.require(resource_key).permit(
:count, :shotengai_series_id :count, :shotengai_series_id
).merge({ remark_input: remark_input, info_input: info_input }) ).merge({ remark_value: remark_value, info_value: info_value })
end end
def edit_only_unpaid def edit_only_unpaid
......
...@@ -39,15 +39,19 @@ module Shotengai ...@@ -39,15 +39,19 @@ module Shotengai
private private
def resource_params def resource_params
spec_input = params.require(resource_key).fetch(:spec_input, nil)&.map(&:permit!) spec_value = params.require(resource_key).fetch(:spec_value, nil)&.map(&:permit!)
info_input = params.require(resource_key).fetch(:info_input, nil)&.map(&:permit!) info_value = params.require(resource_key).fetch(:info_value, nil)&.map(&:permit!)
remark_value = params.require(resource_key).fetch(:remark_value, nil)&.map(&:permit!)
meta = params.require(resource_key).fetch(:meta, nil).try(:permit!) meta = params.require(resource_key).fetch(:meta, nil).try(:permit!)
# ????????!!!!!, spec_input: [:key, :val] 一样的输出值 却在test报错??? # ????????!!!!!, spec_value: [:key, :val] 一样的输出值 却在test报错???
# QUESTION: WARNING: 文档bug吧????? # QUESTION: WARNING: 文档bug吧?????
params.require(resource_key).permit( params.require(resource_key).permit(
:original_price, :price, :stock#, spec_input: [:key, :val] :original_price, :price, :stock#, spec_value: [:key, :val]
).merge( ).merge(
{ spec_input: spec_input, info_input: info_input, meta: meta } {
spec_value: spec_value, info_value: info_value, remark_value: remark_value,
meta: meta
}
) )
end end
......
...@@ -22,10 +22,10 @@ module Shotengai ...@@ -22,10 +22,10 @@ module Shotengai
private private
def resource_params def resource_params
remark_input = params.require(resource_key).fetch(:remark_input, nil)&.map(&:permit!) remark_value = params.require(resource_key).fetch(:remark_value, nil)&.map(&:permit!)
params.require(resource_key).permit( params.require(resource_key).permit(
:revised_amount :revised_amount
).merge({ remark_input: remark_input }) ).merge({ remark_value: remark_value })
end end
def edit_only_unpaid def edit_only_unpaid
......
...@@ -63,9 +63,9 @@ module Shotengai ...@@ -63,9 +63,9 @@ module Shotengai
def resource_params def resource_params
# QUESTION: need these ? # QUESTION: need these ?
# spec = params.require(resource_key).fetch(:spec, nil).try(:permit!) # spec = params.require(resource_key).fetch(:spec, nil).try(:permit!)
spec_input = params.require(resource_key).fetch(:spec_input, nil)&.map(&:permit!) spec_template = params.require(resource_key).fetch(:spec_template, nil)&.map(&:permit!)
remark_input = params.require(resource_key).fetch(:remark_input, nil)&.map(&:permit!) remark_template = params.require(resource_key).fetch(:remark_template, nil)&.map(&:permit!)
info_input = params.require(resource_key).fetch(:info_input, nil)&.map(&:permit!) info_template = params.require(resource_key).fetch(:info_template, nil)&.map(&:permit!)
detail = params.require(resource_key).fetch(:detail, nil).try(:permit!) detail = params.require(resource_key).fetch(:detail, nil).try(:permit!)
meta = params.require(resource_key).fetch(:meta, nil).try(:permit!) meta = params.require(resource_key).fetch(:meta, nil).try(:permit!)
# NOTE: :catalog_list is a default catalog list for template example, maybe should move it to the template controller, but it need add controller template for every controller # NOTE: :catalog_list is a default catalog list for template example, maybe should move it to the template controller, but it need add controller template for every controller
...@@ -73,11 +73,12 @@ module Shotengai ...@@ -73,11 +73,12 @@ module Shotengai
:title, :default_series_id, :title, :default_series_id,
:need_express, :need_time_attr, :cover_image, catalog_ids: [], :need_express, :need_time_attr, :cover_image, catalog_ids: [],
banners: [], banners: [],
# spec_input: [:key, val: []], # spec_template: [:key, val: []],
# remark_input: [:key, :val], # remark_template: [:key, :val],
).merge( ).merge(
{ {
spec_input: spec_input, remark_input: remark_input, info_input: info_input, spec_template: spec_template, remark_template: remark_template,
info_template: info_template,
detail: detail, meta: meta detail: detail, meta: meta
} }
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment