ご教授願います
発生している問題・エラーメッセージ
・method delete後下記エラーが発生します。
エラーメッセージ param is missing or the value is empty: task エラー箇所 params.require(:tasks).permit(:name,:description,:complaint)
##コントローラー
class TasksController < ApplicationController def index @tasks = current_user.tasks end def show @task = current_user.tasks.find(params[:id]) end def new @task = Task.new end def edit @task = current_user.tasks.find(params[:id]) end def update @task = current_user.tasks.find(params[:id]) @task.update!(task_params) redirect_to tasks_url,notice:"やりたいことリスト変更完了!!" end def create @task = Task.new(task_params.merge(user_id: current_user.id)) if @task.save #redirect_to @task, notice: "やりたいこと 「#{task.name}」を記録しました!!" redirect_to @task else render :new end end def destroy @task = current_user.tasks.new(task_params) task.destroy redirect_to tasks_url, notice: "やりたいことを一旦中止しましたが、またやりたくなったらやれば良いのです" end private def task_params params.require(:task).permit(:name,:description,:complaint) #params.(:task).permit(:name,:description,:complaint) end end
##View
- if task.errors.present? ul#error_explanation - task.errors.full_messages.each do |message| li = message = form_with model: task, local: true do |f| .form-group =f.label :name =f.text_field :name,class: 'form-control' , id: 'task_name' .form-group = f.label :description = f.text_area :description, rows: 5, class: 'form-control', id: 'task_description' .form-group = f.label :complaint = f.text_area :complaint,rows: 5, class: 'form-control', id: 'task_complaint' = f.submit nil, class: 'btn btn-primary'
h1 やりたいことの詳細 .nav.justify-content-end = link_to '一覧' , tasks_path,class: 'navi-link' table.table.table-hover tbody tr th = Task.human_attribute_name(:id) td = @task.id tr th = Task.human_attribute_name(:name) td = @task.name tr th = Task.human_attribute_name(:description) td = simple_format(h(@task.description),{},sanitize:false,wrapper_tag:"div") tr th = Task.human_attribute_name(:complaint) td = simple_format(h(@task.complaint),{},sanitize:false,wrapper_tag:"div") tr th = Task.human_attribute_name(:created_at) td = @task.created_at tr th = Task.human_attribute_name(:updated_at) td = @task.updated_at = link_to '変更' ,edit_task_path, class: 'btn btn-primary mr-3' = button_to '一旦止める', @task, method: :delete, data: {confirm: "一旦止めますか?"}, class: 'btn btn-danger'
試したこと
https://stackoverflow.com/questions/30825735/param-is-missing-or-the-value-is-empty-parametermissing-in-resultscontrollerup/30826895
https://stackoverflow.com/questions/26150329/error-param-is-missing-or-the-value-is-empty-article
補足情報(FW/ツールのバージョンなど)
ruby 2.4.5p335 (2018-10-18 revision 65137) [x64-mingw32]
Rails 5.2.3
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/22 12:13