Class: RailsExecution::CommentsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/rails_execution/comments_controller.rb

Instance Method Summary collapse

Methods included from PolicyHelper

#can_close_task?, #can_create_task?, #can_edit_task?, #can_execute_task?, #display_decide?, #display_owner?, #display_reviewers?, #how_to_executable, #in_solo_mode?, #show_form_sidebar?

Methods included from BaseHelper

#current_owner

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
# File 'app/controllers/rails_execution/comments_controller.rb', line 6

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

#updateObject



16
17
18
19
20
# File 'app/controllers/rails_execution/comments_controller.rb', line 16

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