Sha256: cd1bc769c4057a233c1ba98e89c97b5dc7246504477747d15c6c1d44e3372ce5
Contents?: true
Size: 802 Bytes
Versions: 4
Compression:
Stored size: 802 Bytes
Contents
module Theblog class CommentsController < Theblog::ApplicationController before_action :authenticate_account! def create @comment = node.comments.new(comment_params.merge(author_id: current_account.id)) if @comment.save redirect_to path_to_content_node(node) else render 'content_nodes/show' end end def destroy authorize comment, :delete? comment.delete redirect_to path_to_content_node(comment.post) end private def node @node ||= Post.find_by!(id: comment_params[:parent_node_id]) end private def comment_params params.require(:comment).permit(:body, :parent_node_id) end private def comment @comment ||= Comment.find(params[:id]) end helper_method :comment end end
Version data entries
4 entries across 4 versions & 1 rubygems