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

  def index
    @question = Question.find(params[:question_id])
    @comments = @question.comments
  end

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

  def create
    @question = Question.find(params[:question_id])
    @comment = Comment.new comment_params
    if @comment.save
      redirect_to '/' # this isn't working
    else
      render :new<commit_msg>WIP refactoring controller to support both questions and answers<commit_after>class CommentsController < ApplicationController
  before_action :set_comment, only: [:show, :destroy]

  def index
    @question = Question.find(params[:question_id])
    @comments = @question.comments
  end

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

  def create
    @question = Question.find(params[:question_id])

    @comment = Comment.new comment_params
    if @comment.save
      redirect_to '/' # this isn't working
    else
      render :new
{'fraction_non_alphanumeric': 0.09001636661211129, 'fraction_numerical': 0.0, 'mean_word_length': 3.5977443609022557, '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': '1365760', 'n_tokens_mistral': 351, 'n_tokens_neox': 341, 'n_words': 103}