<commit_before>class VotesController < ApplicationController
  before_action :require_login, only: [:create, :update]

  def create
    question = Question.find(params[:question_id])
    if params[:vote] == 'up'
      vote = question.votes.find_or_initialize_by(upvote: true, user: current_user)
    else
      vote = question.votes.find_or_initialize_by(upvote: false, user: current_user)
    end
    if vote.save
      redirect_to :root
    else
      render :root
    end<commit_msg>Let user have ability to change vote up or down<commit_after>class VotesController < ApplicationController
  before_action :require_login, only: [:create, :update]

  def create
    question = Question.find(params[:question_id])
    if params[:vote] == 'up'
      vote = question.votes.find_or_initialize_by(user: current_user)
      vote.upvote = true
    else
      vote = question.votes.find_or_initialize_by(user: current_user)
      vote.upvote = false
    end
    if vote.save
      redirect_to :root
    else
      render :root
    end
{'fraction_non_alphanumeric': 0.08754863813229571, 'fraction_numerical': 0.0, 'mean_word_length': 3.473913043478261, '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': '5697393', 'n_tokens_mistral': 314, 'n_tokens_neox': 313, 'n_words': 78}