<commit_before>class TodoListsController < ApplicationController
  before_action :set_todo_list, only: [:show, :edit, :update, :destroy]
  def index
    @todo_lists = TodoList.all
  end

  def show
    @todo_items = @todo_list.todo_items
    @todo_item = TodoItem.new
  end

  def edit
  end

  def update
    if @todo_list.update(todo_list_params)
      flash[:notice] = 'Todo List successfully updated.'
      redirect_to @todo_list
    else
      flash[:error] = 'Validation errors.'
      render :edit
    end
  end

  def new
    @todo_list = TodoList.new
  end

  def create
    @todo_list = TodoList.new(todo_list_params)
    if @todo_list.save
      flash[:notice] = 'Todo List successfully created.'
      redirect_to @todo_list
    else
      flash[:error] = 'Validation errors.'
      render :new
    end
  end

  def destroy
    @todo_list.destroy
    redirect_to todo_lists_url
  end

  private

  def set_todo_list
    @todo_list = TodoList.find(params[:id])
  end

  def todo_list_params
    params.require(:todo_list).permit(:name, :description)
  end
end
<commit_msg>Flashes with render shouldn't persist to next page<commit_after>class TodoListsController < ApplicationController
  before_action :set_todo_list, only: [:show, :edit, :update, :destroy]
  def index
    @todo_lists = TodoList.all
  end

  def show
    @todo_items = @todo_list.todo_items
    @todo_item = TodoItem.new
  end

  def edit
  end

  def update
    if @todo_list.update(todo_list_params)
      flash[:notice] = 'Todo List successfully updated.'
      redirect_to @todo_list
    else
      flash.now[:error] = 'Validation errors.'
      render :edit
    end
  end

  def new
    @todo_list = TodoList.new
  end

  def create
    @todo_list = TodoList.new(todo_list_params)
    if @todo_list.save
      flash[:notice] = 'Todo List successfully created.'
      redirect_to @todo_list
    else
      flash.now[:error] = 'Validation errors.'
      render :new
    end
  end

  def destroy
    @todo_list.destroy
    redirect_to todo_lists_url
  end

  private

  def set_todo_list
    @todo_list = TodoList.find(params[:id])
  end

  def todo_list_params
    params.require(:todo_list).permit(:name, :description)
  end
end

{'fraction_non_alphanumeric': 0.08450067781292363, 'fraction_numerical': 0.0, 'mean_word_length': 3.010869565217391, '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': '4541227', 'n_tokens_mistral': 788, 'n_tokens_neox': 765, 'n_words': 183}