I implemented the task edit screen, edited it for confirmation, and pressed the button, but the screen did not change. .. .. .. : confounded:
As a result, it was not "redirect_to": sweat_smile :, but I will keep a memorandum of the process until the error was resolved!
[Premise] After pressing the registration button on the edit screen, the button could not be pressed. No screen transitions are made. ① Check if the edited data is saved in MySQL → Changed: ok_hand:
(2) If the error screen does not appear, check that the error information is entered in the terminal.
terminal
No template found for TasksController#update, rendering head :no_content
Completed 204 No Content in 139ms (ActiveRecord: 3.4ms)
There was: rolling_eyes: It says ** No template **! !!
③ Check the controller → redirect_to is not listed: scream:
Before correction
tasks_controller.rb
def update
@task.update(task_params)
if @task.valid?
@task.save
else
flash.now[:alert] = 'Please enter the task name'
render :index
end
end
Revised
tasks_controller.rb
def update
@task.update(task_params)
if @task.valid?
@task.save
redirect_to group_tasks_path(@group), notice: 'Task changed'
else
flash.now[:alert] = 'Please enter the task name'
render :index
end
end
Please be careful, everyone: bow_tone1:
URL for error 204. https://developer.mozilla.org/ja/docs/Web/HTTP/Status/204
Recommended Posts