<commit_before>class CommentsController < ApplicationController
  before_action :set_comment, only: [:show, :destroy]

  def create

  end

  def new
    @comment = Comment.new
  end

  def show

  end

  def destroy

  end

  private

  def set_comment
    @comment = Comment.find(params[:id])
  end

  def comment_params
    params.require(:comment).permit(:content, :parent_id, :parent_type, :author_id)
  end
<commit_msg>new comment form now saves comment<commit_after>class CommentsController < ApplicationController
  before_action :set_comment, only: [:show, :destroy]

  def new
    @comment = Comment.new
    @question = Question.find(params[:question_id])
    # refactor the above to take the parent id or type
  end

  def create
    @comment = Comment.new comment_params
    if @comment.save
      redirect_to '/'
    else
      render :new
    end
  end

  def show
  end

  def destroy
    @comment.destroy
    #redirect to current question
  end

  private

  def set_comment
    @comment = Comment.find(params[:id])
  end

  def comment_params
    params.require(:comment).permit(:content, :parent_id, :parent_type, :author_id)
  end

{'fraction_non_alphanumeric': 0.08260869565217391, 'fraction_numerical': 0.0, 'mean_word_length': 3.310861423220974, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2975430', 'n_tokens_mistral': 365, 'n_tokens_neox': 347, 'n_words': 102}