こんばんわ。現在プログラミングをしており、不明点があります。
referencesでプログラムを組んだコメントを削除しようとした際、削除に対して
show
1ActionView::Template::Error (No route matches {:action=>"show", :company_id=>#<Company id: 1, user_id: 1, agree_check: nil, company:... updated_at: nil>}, possible unmatched constraints: [:id]): 2 270: <th width="60%"><%= comment.body %></th> 3 271: <td width="20%"><%= comment.created_at %></td> 4 272: <td width="20%"><%= link_to '削除', 5 273: mypage_company_comment_path(@company, comment), 6 274: method: :delete, 7 275: class: :"btn btn-primary", 8 276: data: { confirm: '本当に削除しますか?'} %></td> 9
上記のようなエラーが発生します。
問題点としては、273行目の()内の記法かと思うのですが自己解決出来ません。
commentscontroller
1class Mypage::CommentsController < ApplicationController 2 3 def create 4 @company = Company.find(params[:company_id]) 5 @company.comments.create(comment_params) 6 redirect_to mypage_company_path(@company) 7 end 8 9 def destroy 10 @company = Company.find(params[:company_id]) 11 @comment = @company.comments.find(params[:id]) 12 @company.destroy 13 redirect_to mypage_company_path(@company) 14 end 15 16 private 17 def comment_params 18 params.require(:comment).permit(:body) 19 end 20 21end 22
ご教示よろしくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。