この動画をみながらサイトを作っていたのですが、
以下のようなエラーが出てしまいました。
削除ボタンを押したらこれが出て、エラーが出るのですが、Comments#indexはどっから出てきたのでしょうか?
おそらく、削除したあとのリダレクト先なのでしょうが、その記述が書いてある場所が分かりません。
なので、Comments#indexのどこがいけないのかわからないのですが、教えていただけないでしょうか?
class CommentsController < ApplicationController before_action :set_comment, only: [:show, :edit, :update, :destroy] def create @link = Link.find(params[:link_id]) @comment = @link.comments.new(comment_params) @comment.user = current_user respond_to do |format| if @comment.save format.html { redirect_to @link, notice: 'Comment was successfully created.' } format.json { render json: @comment, status: :created, location: @comment } else format.html { render action: "new" } format.json { render json: @comment.errors, status: :unprocessable_entity } end end end # DELETE /comments/1 # DELETE /comments/1.json def destroy @comment.destroy respond_to do |format| format.html { redirect_to comments_url, notice: 'Comment was successfully destroyed.' } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. def set_comment @comment = Comment.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def comment_params params.require(:comment).permit(:link_id, :body, :user_id) end end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/10/04 12:06
2017/10/06 02:34
2017/10/06 03:56