Class: Tracebook::CommentsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/tracebook/comments_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_tracebook_user_label, #render_not_found

Instance Method Details

#comment_paramsObject (private)



21
22
23
# File 'app/controllers/tracebook/comments_controller.rb', line 21

def comment_params
  params.require(:comment).permit(:body)
end

#createObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/tracebook/comments_controller.rb', line 5

def create
  chat = Tracebook.config.chat_model.find(params[:chat_id])
  review = ChatReview.for_chat(chat)

  comment = review.comments.build(comment_params)
  comment.author = current_tracebook_user_label

  if comment.save
    redirect_to chat_path(chat), notice: "Comment added"
  else
    redirect_to chat_path(chat), alert: "Failed to add comment"
  end
end