Sha256: 311913de56267317bb292efe2f58b5859aaca8a332f6d58e1009b7b7180aa728

Contents?: true

Size: 1009 Bytes

Versions: 9

Compression:

Stored size: 1009 Bytes

Contents

# frozen_string_literal: true

module RailsExecution
  class CommentsController < ::RailsExecution::BaseController

    def create
      @new_comment = current_task.comments.new(owner: current_owner, content: params.dig(:comment, :content))
      if @new_comment.save
        ::RailsExecution.configuration.notifier.new(current_task).add_comment(current_owner, @new_comment.content)
        current_task.activities.create(owner: current_owner, message: "Added a comment: #{@new_comment.content.truncate(30)}")
      else
        @alert = "Your comment can't adding!"
      end
    end

    def update
      @comment = current_comment
      @comment.update(content: params.dig(:comment, :content))
      respond_to(&:js)
    end

    private

    def current_task
      @current_task ||= RailsExecution::Task.find(params[:task_id])
    end
    helper_method :current_task

    def current_comment
      @comment ||= current_task.comments.find(params[:id])
    end
    helper_method :current_comment

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails_execution-0.1.12 app/controllers/rails_execution/comments_controller.rb
rails_execution-0.1.11 app/controllers/rails_execution/comments_controller.rb
rails_execution-0.1.10 app/controllers/rails_execution/comments_controller.rb
rails_execution-0.1.9 app/controllers/rails_execution/comments_controller.rb
rails_execution-0.1.8 app/controllers/rails_execution/comments_controller.rb
rails_execution-0.1.7 app/controllers/rails_execution/comments_controller.rb
rails_execution-0.1.5 app/controllers/rails_execution/comments_controller.rb
rails_execution-0.1.4 app/controllers/rails_execution/comments_controller.rb
rails_execution-0.1.2 app/controllers/rails_execution/comments_controller.rb