Sha256: f56cd43782323f18b245fcd0633bb9e23c5a514136755514b28006965314030e
Contents?: true
Size: 900 Bytes
Versions: 3
Compression:
Stored size: 900 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 @comment.notify :admins 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
3 entries across 3 versions & 1 rubygems