Sha256: f50f99caccdd33cab577d52a314bcff47b877825142498e494a9b42de632fce5
Contents?: true
Size: 870 Bytes
Versions: 15
Compression:
Stored size: 870 Bytes
Contents
class CommentsController < ApplicationController before_action :set_comment, only: [:destroy] # POST /comments def create @comment = Comment.new(comment_params) @comment.user = current_user if @comment.save @comment.notify :users redirect_to @comment.article, notice: 'Comment was successfully created.' else redirect_to @comment.article end end # DELETE /comments/1 def destroy article = @comment.article @comment.destroy redirect_to article, notice: 'Comment was successfully destroyed.' end private # Use callbacks to share common setup or constraints between actions. def set_comment @comment = Comment.find(params[:id]) end # Only allow a trusted parameter "white list" through. def comment_params params.require(:comment).permit(:article_id, :body) end end
Version data entries
15 entries across 15 versions & 1 rubygems