Commit 474d25e2 authored by Shinya Maeda's avatar Shinya Maeda

Use variable_params && variable_params_attributes in project variables_controller.rb

parent 4fbfe475
...@@ -12,7 +12,7 @@ class Projects::VariablesController < Projects::ApplicationController ...@@ -12,7 +12,7 @@ class Projects::VariablesController < Projects::ApplicationController
end end
def update def update
if @variable.update(project_params) if variable.update(variable_params)
redirect_to project_variables_path(project), redirect_to project_variables_path(project),
notice: 'Variable was successfully updated.' notice: 'Variable was successfully updated.'
else else
...@@ -21,7 +21,7 @@ class Projects::VariablesController < Projects::ApplicationController ...@@ -21,7 +21,7 @@ class Projects::VariablesController < Projects::ApplicationController
end end
def create def create
@variable = project.variables.create(project_params) @variable = project.variables.create(variable_params)
.present(current_user: current_user) .present(current_user: current_user)
if @variable.persisted? if @variable.persisted?
...@@ -46,8 +46,12 @@ class Projects::VariablesController < Projects::ApplicationController ...@@ -46,8 +46,12 @@ class Projects::VariablesController < Projects::ApplicationController
private private
def project_params def variable_params
params.require(:variable).permit([:id, :key, :value, :protected, :_destroy]) params.require(:variable).permit(*variable_params_attributes)
end
def variable_params_attributes
%i[id key value protected _destroy]
end end
def variable def variable
......
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