<commit_before>class DogsController < ApplicationController
  autocomplete :breed, :name, :full => true

  before_filter :admin_user,   :only => [:new, :create, :destroy]

  def index
    @title = "Dogs"
    @dogs = Dog.paginate(:page => params[:page])
  end

  def show
    @dog = Dog.find(params[:id])
    @title = @dog.name
  end

  def new
    @dog = Dog.new
    @title = "Add a New Dog"
  end

  def edit
    @dog = Dog.find(params[:id])
    @dog.primary_breed_name = @dog.primary_breed.name
    @dog.secondary_breed_name = @dog.secondary_breed.name
    @title = "Edit Dog"
  end

  def update
    @dog = Dog.find(params[:id])
    if @dog.update_attributes(params[:dog])
      flash[:success] = "Dog updated."
      redirect_to @dog
    else
      @title = "Edit Dog"
      render 'edit'
    end
  end

  def create
    @dog = Dog.new(params[:dog])
    if @dog.save
      flash[:success] = "New Dog Added"
      redirect_to dogs_path
    else
      @title = "Add a New Dog"
      render 'new'
    end
  end

  def destroy
    Dog.find(params[:id]).destroy
    flash[:success] = "Dog deleted."
    redirect_to dogs_path
  end

  private

    def admin_user
      redirect_to(root_path) unless current_user.admin?
    end


end
<commit_msg>fixed edit bug<commit_after>class DogsController < ApplicationController
  autocomplete :breed, :name, :full => true

  before_filter :admin_user,   :only => [:new, :create, :destroy]

  def index
    @title = "Dogs"
    @dogs = Dog.paginate(:page => params[:page])
  end

  def show
    @dog = Dog.find(params[:id])
    @title = @dog.name
  end

  def new
    @dog = Dog.new
    @title = "Add a New Dog"
  end

  def edit
    @dog = Dog.find(params[:id]) 
    @dog.primary_breed_name = @dog.primary_breed.name unless @dog.primary_breed.nil?
    @dog.secondary_breed_name = @dog.secondary_breed.name unless @dog.secondary_breed.nil?
    @title = "Edit Dog"
  end

  def update
    @dog = Dog.find(params[:id])
    if @dog.update_attributes(params[:dog])
      flash[:success] = "Dog updated."
      redirect_to @dog
    else
      @title = "Edit Dog"
      render 'edit'
    end
  end

  def create
    @dog = Dog.new(params[:dog])
    if @dog.save
      flash[:success] = "New Dog Added"
      redirect_to dogs_path
    else
      @title = "Add a New Dog"
      render 'new'
    end
  end

  def destroy
    Dog.find(params[:id]).destroy
    flash[:success] = "Dog deleted."
    redirect_to dogs_path
  end

  private

    def admin_user
      redirect_to(root_path) unless current_user.admin?
    end


end

{'fraction_non_alphanumeric': 0.1206896551724138, 'fraction_numerical': 0.0, 'mean_word_length': 2.6471428571428572, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '800362', 'n_tokens_mistral': 908, 'n_tokens_neox': 874, 'n_words': 224}