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

Version Path
activity_notification-1.6.1 spec/rails_app/app/controllers/comments_controller.rb
activity_notification-1.6.0 spec/rails_app/app/controllers/comments_controller.rb
activity_notification-1.5.1 spec/rails_app/app/controllers/comments_controller.rb
activity_notification-1.5.0 spec/rails_app/app/controllers/comments_controller.rb
activity_notification-1.4.4 spec/rails_app/app/controllers/comments_controller.rb
activity_notification-1.4.3 spec/rails_app/app/controllers/comments_controller.rb
activity_notification-1.4.2 spec/rails_app/app/controllers/comments_controller.rb
activity_notification-1.4.1 spec/rails_app/app/controllers/comments_controller.rb
activity_notification-1.4.0 spec/rails_app/app/controllers/comments_controller.rb
activity_notification-1.1.0 spec/rails_app/app/controllers/comments_controller.rb
activity_notification-1.0.2 spec/rails_app/app/controllers/comments_controller.rb
activity_notification-1.0.1 spec/rails_app/app/controllers/comments_controller.rb
activity_notification-1.0.0 spec/rails_app/app/controllers/comments_controller.rb
activity_notification-0.0.10 spec/rails_app/app/controllers/comments_controller.rb
activity_notification-0.0.9 spec/rails_app/app/controllers/comments_controller.rb