Looking at it, the 51st line is suspicious. The 50th line gets a specific record from the task table and assigns it to @task. And on line 51 there is an if statement saying if it is updated. Pay attention to @task here. Since update is an action that replaces the updated data, it also saves to the table through the model, so there is something you need. This is a strong parameter to prevent unintended data registration / update. Where are the strong parameters?
private
def task_params
params.require(:task).permit(:content, :point_id).merge(user_id: current_user.id)
end
It is already prepared under private, and is also required when creating. It was necessary to pass the task_params defined here as an argument. Therefore, it was scolded if the number of arguments was not correct and caused an error.
def update
@task = Task.find(params[:id])
if @task.update(task_params)← Added here
redirect_to root_path
end
This was able to eliminate the error.
Recommended Posts