<commit_before>class CommentsController < ApplicationController

  def index
    @comments = Comment.all
  end

  def new
    @comment = Comment.new
  end

end<commit_msg>adds a create action in comments controller<commit_after>class CommentsController < ApplicationController

  def index
    @comments = Comment.all
  end

  def create
    @comment = Comment.new(comment_params)
    @question = Question.find_by(id: comment_params[:commentable_id])
    if @question.comments << @comment
      redirect_to :back
    else
      flash[:notice] = "There was a problem submitting your comment."
      redirect_to :back
    end
  end



  private
    def comment_params
      params.require(:comment).permit(:body, :commentable_id, :commentable_type, :user_id)
    end
end
{'fraction_non_alphanumeric': 0.07682291666666667, 'fraction_numerical': 0.0, 'mean_word_length': 3.5502958579881656, 'pattern_counts': {'":': 0, '<': 7, '<?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': '975527', 'n_tokens_mistral': 224, 'n_tokens_neox': 215, 'n_words': 61}