rails-refresher/app/controllers/comments_controller.rb
Tyrel Souza 8a91d51c39
finish
2024-07-04 21:00:08 -04:00

20 lines
527 B
Ruby

class CommentsController < ApplicationController
def create
@article = Article.find(params[:article_id])
@comment = @article.comments.create(comment_params)
redirect_to article_path(@article)
end
def destroy
@article = Article.find(params[:article_id])
@comment = @article.comments.find(params[:id])
@comment.destroy
redirect_to article_path(@article), status: :see_other
end
private
def comment_params
params.require(:comment).permit(:commenter, :body, :status)
end
end