<commit_before>class HuntsController < ApplicationController
  before_action :set_hunt, only: [:show, :edit, :destroy, :update]


  def index
    @hunts = current_user.hunts
  end

  def new
    @hunt      = Hunt.new
    @locations = current_user.locations
  end

  def create
    create_with_teams

  end

  def edit
    @locations = current_user.locations
  end

  def update
    if @hunt.update_attributes(hunt_params)
      redirect_to hunt_path(@hunt)
    else
      render :edit, notice: "Hunt could not be updated. Try again."
    end
  end

  def destroy
    if @hunt.destroy
      redirect_to hunts_path
    else
      redirect_to hunts_path, notice: "Hunt could not be destroyed. Try again."
    end
  end

  private

  def create_with_teams
    hunt.transaction do
      hunt = current_user.hunts.create(hunt_params)
      hunt.make_teams(params[:number_of_teams])
    end
  end<commit_msg>view and routes are working<commit_after>class HuntsController < ApplicationController
  before_action :set_hunt, only: [:show, :edit, :destroy, :update]


  def index
    @hunts = current_user.hunts
  end

  def new
    @hunt      = Hunt.new
    @locations = current_user.locations
  end

  def create
    if create_with_teams
      redirect_to hunt_path(@hunt), notice: "well done"
    end
  end

  def edit
    @locations = current_user.locations
  end

  def update
    if @hunt.update_attributes(hunt_params)
      redirect_to hunt_path(@hunt)
    else
      render :edit, notice: "Hunt could not be updated. Try again."
    end
  end

  def destroy
    if @hunt.destroy
      redirect_to hunts_path
    else
      redirect_to hunts_path, notice: "Hunt could not be destroyed. Try again."
    end
  end

  private

  def create_with_teams
    Hunt.transaction do
      @hunt = current_user.hunts.create(hunt_params)
      @hunt.make_teams(params[:number_of_teams].to_i)
    end
  end
{'fraction_non_alphanumeric': 0.07093700370566437, 'fraction_numerical': 0.0, 'mean_word_length': 2.872950819672131, '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': '6419957', 'n_tokens_mistral': 646, 'n_tokens_neox': 622, 'n_words': 168}