<commit_before>class CommentsController < ApplicationController
  include AuthsHelper

  def create
    @question = Question.find(q_params[:question_id])
    @comment = Comment.new(comment_params)
    if @comment.save
      redirect_to question_path(@question)
    else
      #error_message?
      render :new
    end
  end

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

  def update
    @comment = Comment.find(params[:id])
    @question = Question.find(@comment.get_question_id)
    if @comment.update(comment_params)
      redirect_to question_path(@question)
    else
      render :edit
    end
  end

  def destroy
    @comment = Comment.find(params[:id])
    @comment.destroy
    redirect_to :back
  end


  private
    def comment_params
      params.require(:comment).permit(:commentable_id, :commentable_type, :body, :user_id)
    end
    def q_params
      params.require(:comment).permit(:question_id)
    end


end<commit_msg>Fix logged_in check for edit/delete buttons.<commit_after>class CommentsController < ApplicationController
  include AuthsHelper

  def create
    @comment = Comment.new(comment_params)
    if @comment.save
      @question = Question.find(@comment.get_question_id)
      redirect_to question_path(@question)
    else
      #error_message?
      render :new
    end
  end

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

  def update
    @comment = Comment.find(params[:id])
    if @comment.update(comment_params)
      @question = Question.find(@comment.get_question_id)
      redirect_to question_path(@question)
    else
      render :edit
    end
  end

  def destroy
    @comment = Comment.find(params[:id])
    @comment.destroy
    redirect_to :back
  end

  private
    def comment_params
      params.require(:comment).permit(:commentable_id, :commentable_type, :body, :user_id)
    end
    def q_params
      params.require(:comment).permit(:question_id)
    end
end
{'fraction_non_alphanumeric': 0.09245867768595041, 'fraction_numerical': 0.0, 'mean_word_length': 3.2292576419213974, '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': '6337453', 'n_tokens_mistral': 593, 'n_tokens_neox': 580, 'n_words': 128}