<commit_before>class CommentsController < ApplicationController

  def create
    @comment = Comment.new(comment_params)
    if @comment.save
      if @comment.commentable_type == 'Question'
        @question = Question.find(@comment.commentable_id)
        @question.comments << @comment.save
        render json: @comment.to_json
      else if @comment.commentable_type == 'Answer'
        @answer = Answer.find(@comment.commentable_id)
        @answer.comments << @comment.save
        render json: @comment.to_json
      else
        redirect_to :back
      end
  end

  private

    def comment_params
      params.require(:comment).permit(:body, :user_id, :commentable_type, :commentable_id)
    end

end<commit_msg>passed user_id to comments<commit_after>class CommentsController < ApplicationController

  def create
    @comment = Comment.new(comment_params)
    @comment.user_id = current_user.id
    if @comment.save
      if @comment.commentable_type == 'Question'
        @question = Question.find(@comment.commentable_id)
        @question.comments << @comment.save
        render json: @comment.to_json
      else if @comment.commentable_type == 'Answer'
        @answer = Answer.find(@comment.commentable_id)
        @answer.comments << @comment.save
        render json: @comment.to_json
      else
        redirect_to :back
      end
  end

  private

    def comment_params
      params.require(:comment).permit(:body, :user_id, :commentable_type, :commentable_id)
    end

end
{'fraction_non_alphanumeric': 0.0962566844919786, 'fraction_numerical': 0.0, 'mean_word_length': 3.035040431266846, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1673294', 'n_tokens_mistral': 437, 'n_tokens_neox': 427, 'n_words': 92}