Answer the question
In order to leave comments, you need to log in
[param is missing or the value is empty: task] How to solve?
I am making a ToDo application (everything I am doing now is purely for practicing skills, understanding where the gaps are). I ran into a problem, I don’t know how to implement the following:
When you click on the checkmark, the task parameter :complete_task changes from false to true.
I decided that I have a problem with the design of routes. I tried to implement it myself as follows: I
created a method in the task controller
def complete_todo
@task = Task.find(params[:id])
@task.complete_task = true
if @task.update(task_params)
redirect_to root_path
end
end
post 'tasks/complete_todo/:id', to: 'tasks#complete_todo', as: 'finished_task'
param is missing or the value is empty: task
Answer the question
In order to leave comments, you need to log in
param is missing or the value is empty: task
@task.complete!
post 'tasks/:id/complete', to: 'tasks#complete', as: 'complete_task'
- that would have been better. Rename the action accordingly. resources :tasks do
post :complete, on: :member
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question