<commit_before>class BidsController < ApplicationController
  before_action :set_round,  only: [:index, :create]
  before_action :set_player, only: [:create]

  def index
    @bids = @round.bids.all
    render :index, status: 200, locals: {errors: []}
  end

  def create
    submit_bid = SubmitBid.new(@round, @player, bid_params[:number_of_tricks], bid_params[:suit])

    submit_bid.call

    @bids = @round.bids.all

    if submit_bid.errors.empty?
      render json: submit_bid.round, serializer: RoundSerializer, status: :created, locals: { errors: [] }
    else
      render json: { errors: submit_bid.errors }, status: :unprocessable_entity
    end
  end

  private

  def set_round
    @round = Round.find(bid_params[:round_id])
  end

  def set_player
    @player = Player.find_by(user: current_user)
  end

  def bid_params
    params.permit(:round_id, :number_of_tricks, :suit)
  end
end<commit_msg>Fix bug where users were being confused across multiple rounds<commit_after>class BidsController < ApplicationController
  before_action :set_round,  only: [:index, :create]
  before_action :set_player, only: [:create]

  def create
    submit_bid = SubmitBid.new(@round, @player, bid_params[:number_of_tricks], bid_params[:suit])

    submit_bid.call

    @bids = @round.bids.all

    if submit_bid.errors.empty?
      render json: submit_bid.round, serializer: RoundSerializer, status: :created, locals: { errors: [] }
    else
      render json: { errors: submit_bid.errors }, status: :unprocessable_entity
    end
  end

  private

  def set_round
    @round = Round.find(bid_params[:round_id])
  end

  def set_player
    @player = @round.game.players.find_by(user: current_user)
  end

  def bid_params
    params.permit(:round_id, :number_of_tricks, :suit)
  end
end
{'fraction_non_alphanumeric': 0.10650224215246637, 'fraction_numerical': 0.0016816143497757848, 'mean_word_length': 3.9583333333333335, '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': '7639634', 'n_tokens_mistral': 611, 'n_tokens_neox': 590, 'n_words': 141}