<commit_before>class AnswersController < ApplicationController
  before_action :login_check, only: [:show, :create, :destroy]
  before_action :set_answer, only: :destroy

  api :GET, '/answers', '특정 question에 대한 학생들의 답'
  param :question_id, :number, :desc => "질문 ID", :required => true
  def show
    @answers = Answer.where(question_id: params[:question_id])
  end

  api :POST, '/answers', '특정 question에 대한 학생의 답 생성'
  param :question_id, :number, :desc => "질문 ID", :required => true
  param :answer, String, :desc => "학생 답", :required => true
  def create
    @answer = Answer.new(answer_params)

      if @answer.save
        render json: @answer, status: :ok
      else
        render json: {message: "답은 반드시 입력해야 합니다."}, status: :bad_request
      end
  end

  # DELETE /answers/1
  # DELETE /answers/1.json
  def destroy
    @answer.destroy
    head :ok
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_answer
      @answer = Answer.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def answer_params
      params[:user_id] = session[:user_id]
      params.permit(:user_id, :question_id, :answer)
    end
end<commit_msg>answer 컨트롤러 수정<commit_after>class AnswersController < ApplicationController
  before_action :login_check, only: [:show, :create, :destroy]
  before_action :set_answer, only: :destroy

  api :GET, '/answers', '특정 question에 대한 학생들의 답'
  param :question_id, :number, :desc => "질문 ID", :required => true
  def show
    @answers = Answer.where(question_id: params[:question_id])
  end

  api :POST, '/answers', '특정 question에 대한 학생의 답 생성'
  param :question_id, :number, :desc => "질문 ID", :required => true
  param :answer, String, :desc => "학생 답", :required => true
  def create
    @answer = Answer.new(answer_params)

      if @answer.save
        render json: @answer, status: :ok
      else
        render json: {message: "답은 반드시 입력해야 합니다."}, status: :bad_request
      end
  end

  # DELETE /answers/1
  # DELETE /answers/1.json
  api :DELETE, '/answers', '특정 question에 대한 학생 답 삭제'
  param :id, :number, :desc => "학생 답 ID", :required => true
  def destroy
    @answer.destroy
    head :ok
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_answer
      @answer = Answer.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def answer_params
      params[:user_id] = session[:user_id]
      params.permit(:user_id, :question_id, :answer)
    end
end
{'fraction_non_alphanumeric': 0.11573720397249809, 'fraction_numerical': 0.0015278838808250573, 'mean_word_length': 3.2934426229508196, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '7303903', 'n_tokens_mistral': 922, 'n_tokens_neox': 985, 'n_words': 281}