<commit_before>class DogController < ApplicationController
  before do
    if !logged_in?
      redirect '/login'
    end
  end

  get '/dogs' do
    @dogs = current_user.dogs
    erb :'dogs/index'
  end

  get '/dogs/new' do
    erb :'dogs/new'
  end

  get '/dogs/:id' do
    @dog = Dog.find(params[:id])
    erb :'dogs/show'
  end

  post '/dogs' do
    current_user.dogs.build(name: params[:name]).save
    redirect '/dogs'
  end

  get '/dogs/:id/edit' do
    @dog = Dog.find(params[:id])
    if @dog.user_id == current_user.id
      erb :'dogs/edit'
    else
      redirect '/dogs'
    end
  end

  patch '/dogs/:id' do
    dog = Dog.find(params[:id])
    if dog.user_id == current_user.id
      dog.update(name: params[:name])
    end
    redirect '/dogs'
  end

  delete '/dogs/:id/delete' do
    dog = Dog.find(params[:id])
    if dog.user_id == current_user.id
      Dog.destroy(dog.id)
    end
    redirect '/dogs'
  end
end<commit_msg>Add flash messages to dogs.<commit_after>require 'rack-flash'

class DogController < ApplicationController
  use Rack::Flash

  before do
    if !logged_in?
      redirect '/login'
    end
  end

  get '/dogs' do
    @dogs = current_user.dogs
    erb :'dogs/index'
  end

  get '/dogs/new' do
    erb :'dogs/new'
  end

  get '/dogs/:id' do
    @dog = Dog.find(params[:id])
    erb :'dogs/show'
  end

  post '/dogs' do
    current_user.dogs.build(name: params[:name]).save
    flash[:message] = "Successfully added a dog!"
    redirect '/dogs'
  end

  get '/dogs/:id/edit' do
    @dog = Dog.find(params[:id])
    if @dog.user_id == current_user.id
      erb :'dogs/edit'
    else
      redirect '/dogs'
    end
  end

  patch '/dogs/:id' do
    dog = Dog.find(params[:id])
    if dog.user_id == current_user.id
      dog.update(name: params[:name])
      flash[:message] = "Successfully updated a dog!"
    end
    redirect '/dogs'
  end

  delete '/dogs/:id/delete' do
    dog = Dog.find(params[:id])
    if dog.user_id == current_user.id
      Dog.destroy(dog.id)
      flash[:message] = "Successfully deleted a dog!"
    end
    redirect '/dogs'
  end
end
{'fraction_non_alphanumeric': 0.14095870906502136, 'fraction_numerical': 0.0, 'mean_word_length': 2.405492730210016, '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': '6794003', 'n_tokens_mistral': 801, 'n_tokens_neox': 791, 'n_words': 190}