<commit_before>class CommentsController < ApplicationController

  def new
    @resource = Resource.find_by(id: params[:resource_id])
    @comment = @resource.comments.build
  end

  def create
    @resource = Resource.find_by(id: params[:resource_id])
    @comment = @resource.comments.build(comment_params)
    @comment.user = current_user
    raise @comment.inspect
  end

  private

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

end<commit_msg>Complete destroy action for comments controller.<commit_after>class CommentsController < ApplicationController

  def new
    @resource = Resource.find_by(id: params[:resource_id])
    @comment = @resource.comments.build
  end

  def create
    @resource = Resource.find_by(id: params[:resource_id])
    @comment = @resource.comments.build(comment_params)
    @comment.user = current_user
    if @resource.save
      redirect_to resource_path(@resource)
    else
      flash[:error] = @comment.errors.full_messages
      redirect_to resource_path(@resource)
    end
  end

  def destroy
    @comment = Comment.find_by(id: params[:id])
    @resource = @comment.resource
    @comment.destroy if correct_user?
    redirect_to resource_path(@resource)
  end

  private

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

end
{'fraction_non_alphanumeric': 0.09541697971450037, 'fraction_numerical': 0.0, 'mean_word_length': 3.808664259927798, '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': '1351816', 'n_tokens_mistral': 390, 'n_tokens_neox': 380, 'n_words': 83}