Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shotengai
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
shotengai
Commits
8adb9b64
Commit
8adb9b64
authored
Mar 16, 2018
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve params permit code style
parent
76881578
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
15 deletions
+11
-15
product_series_controller.rb
...hotengai/controller/merchant/product_series_controller.rb
+5
-7
product_snapshots_controller.rb
...engai/controller/merchant/product_snapshots_controller.rb
+2
-2
products_controller.rb
lib/shotengai/controller/merchant/products_controller.rb
+4
-6
No files found.
lib/shotengai/controller/merchant/product_series_controller.rb
View file @
8adb9b64
...
...
@@ -39,21 +39,19 @@ module Shotengai
private
def
resource_params
spec_value
=
params
.
require
(
resource_key
).
fetch
(
:spec_value
,
nil
)
&
.
map
(
&
:permit!
)
info_template
=
params
.
require
(
resource_key
).
fetch
(
:info_template
,
nil
)
&
.
map
(
&
:permit!
)
detail_info_template
=
params
.
require
(
resource_key
).
fetch
(
:detail_info_template
,
nil
)
&
.
map
(
&
:permit!
)
remark_value
=
params
.
require
(
resource_key
).
fetch
(
:remark_value
,
nil
)
&
.
map
(
&
:permit!
)
meta
=
params
.
require
(
resource_key
).
fetch
(
:meta
,
nil
)
&
.
permit!
spec_value
=
params
.
require
(
resource_key
).
fetch
(
:spec_value
,
[])
.
map
(
&
:permit!
)
info_template
=
params
.
require
(
resource_key
).
fetch
(
:info_template
,
[])
.
map
(
&
:permit!
)
detail_info_template
=
params
.
require
(
resource_key
).
fetch
(
:detail_info_template
,
[])
.
map
(
&
:permit!
)
remark_value
=
params
.
require
(
resource_key
).
fetch
(
:remark_value
,
[])
.
map
(
&
:permit!
)
meta
=
params
.
require
(
resource_key
).
fetch
(
:meta
,
{})
.
permit!
# ????????!!!!!, spec_value: [:key, :val] 一样的输出值 却在test报错???
# QUESTION: WARNING: 文档bug吧?????
params
.
require
(
resource_key
).
permit
(
:original_price
,
:price
,
:stock
#, spec_value: [:key, :val]
).
merge
(
{
spec_value:
spec_value
,
info_template:
info_template
,
remark_value:
remark_value
,
detail_info_template:
detail_info_template
,
meta:
meta
}
)
end
...
...
lib/shotengai/controller/merchant/product_snapshots_controller.rb
View file @
8adb9b64
...
...
@@ -22,10 +22,10 @@ module Shotengai
private
def
resource_params
remark_value
=
params
.
require
(
resource_key
).
fetch
(
:remark_value
,
nil
)
&
.
permit!
remark_value
=
params
.
require
(
resource_key
).
fetch
(
:remark_value
,
{})
.
permit!
params
.
require
(
resource_key
).
permit
(
:revised_amount
).
merge
(
{
remark_value:
remark_value
}
)
).
merge
(
remark_value:
remark_value
)
end
def
edit_only_unpaid
...
...
lib/shotengai/controller/merchant/products_controller.rb
View file @
8adb9b64
...
...
@@ -63,10 +63,10 @@ module Shotengai
def
resource_params
# QUESTION: need these ?
# spec = params.require(resource_key).fetch(:spec, nil).try(:permit!)
spec_template
=
params
.
require
(
resource_key
).
fetch
(
:spec_template
,
nil
)
&
.
map
(
&
:permit!
)
remark_template
=
params
.
require
(
resource_key
).
fetch
(
:remark_template
,
nil
)
&
.
map
(
&
:permit!
)
detail
=
params
.
require
(
resource_key
).
fetch
(
:detail
,
nil
)
&
.
permit!
meta
=
params
.
require
(
resource_key
).
fetch
(
:meta
,
nil
)
&
.
permit!
spec_template
=
params
.
require
(
resource_key
).
fetch
(
:spec_template
,
[])
.
map
(
&
:permit!
)
remark_template
=
params
.
require
(
resource_key
).
fetch
(
:remark_template
,
[])
.
map
(
&
:permit!
)
detail
=
params
.
require
(
resource_key
).
fetch
(
:detail
,
{})
.
permit!
meta
=
params
.
require
(
resource_key
).
fetch
(
:meta
,
{})
.
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
params
.
require
(
resource_key
).
permit
(
:title
,
:default_series_id
,
...
...
@@ -75,10 +75,8 @@ module Shotengai
# spec_template: [:key, val: []],
# remark_template: [:key, :val],
).
merge
(
{
spec_template:
spec_template
,
remark_template:
remark_template
,
detail:
detail
,
meta:
meta
}
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment