投稿機能を実装し投稿したものをdeleteしたいのですがUrlGenerationErrorが出ています。
memoのidがnilであると言われているので、コントローラーにidが渡せていないと思うのですが、どこが間違っているのかわかりません。
ご指南いただけると幸いです。
memos.contoroller.rb def destroy @memo = Memo.find(params[:id]) @memo.delete @post = Post.find(params[:post_id]) redirect_to @post end private def memo_params params.require(:memo).permit(:id,:content).merge(post_id: params[:post_id]) end end
_index.html.haml - memos.each do |memo| .memoarea .memoarea__deletebtn = link_to post_memo_path(@post,@memo), method: :delete do = fa_icon 'thumb-tack',class:'fa-2x' .memoarea__memo .memoarea__memo__text #{memo.content}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。