Err in Documentation

You forgot to update Strong params in section 6.4 (deleting comments)
http://guides.rubyonrails.org/getting_started.html

This is your final code:

class CommentsController < ApplicationController

def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create(params[:comment])
redirect_to post_path(@post)
end

def destroy
@post = Post.find(params[:post_id])
@comment = @post.comments.find(params[:id])
@comment.destroy
redirect_to post_path(@post)
end

end

It should be:

class CommentsController < ApplicationController

def create
@post = Post.find(params[:post_id])
@comment =
@post.comments.create(params[:comment].permit(:commenter,
:body))

redirect_to post_path(@post)
end

def destroy
@post = Post.find(params[:post_id])
@comment = @post.comments.find(params[:id])
@comment.destroy
redirect_to post_path(@post)
end

end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs