<commit_before>class CommentsController < ApplicationController

  def index
    @comments = @post.comments.all
  end

  def create
    @post = Post.find(params[:post_id])
    @comment = Comment.new
    if @comment.save
      redirect_to root_path, notice: "Your comment has been published"
    else
      flash.alert = "Your comment could not be published. Please correct the errors below."
      render :new
    end
  end

  private
<commit_msg>fixed comment#ceate association with post<commit_after>class CommentsController < ApplicationController

  def index
    @comments = @post.comments.all
  end

  def create
    @post = Post.find(params[:post_id])
    @comment = @post.comments.create(params[:comment].permit(:body))
    if @comment.save
      redirect_to :back, notice: "Your comment has been published"
    else
      flash.alert = "Your comment could not be published. Please correct the errors below."
      render :new
    end
  end

  private

{'fraction_non_alphanumeric': 0.08229166666666667, 'fraction_numerical': 0.0, 'mean_word_length': 3.2334801762114536, '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': '114982', 'n_tokens_mistral': 270, 'n_tokens_neox': 263, 'n_words': 88}