<commit_before>class TopicsController < ApplicationController
  skip_authorization_check
  before_filter :authenticate_user!

  def index
    @topics = Topic.all
  end

  def show
    @topic = Topic.find_by(params[:name])
    @posts = Post.where(topic: @topic)
  end

  def edit
    @topic = Topic.find(params[:id])
  end

  def new
    @topic = Topic.new
  end

  def create
    @topic = Topic.new(topic_params)
    if @topic.save
      flash[:success] = 'New topic created.'
      redirect_to topics_path
    else
      render 'topics/new'
    end
  end

  def destroy
    Topic.find(params[:id]).destroy
    redirect_to topics_path
  end

  def update
    @topic = Topic.find(params[:id])
    if @topic.update_attributes(topic_params)
      flash[:success] = 'Topic name updated.'
      redirect_to topics_path
    else
      render 'topics/edit'
    end
  end
<commit_msg>fixed topic find methods<commit_after>class TopicsController < ApplicationController
  skip_authorization_check
  before_filter :authenticate_user!

  def index
    @topics = Topic.all
  end

  def show
    @topic = Topic.find_by(params[:name])
    @posts = Post.where(topic: @topic)
  end

  def edit
    @topic = Topic.find_by(params[:name])
  end

  def new
    @topic = Topic.new
  end

  def create
    @topic = Topic.new(topic_params)
    if @topic.save
      flash[:success] = 'New topic created.'
      redirect_to topics_path
    else
      render 'topics/new'
    end
  end

  def destroy
    Topic.find_by(params[:name]).destroy
    redirect_to topics_path
  end

  def update
    @topic = Topic.find_by(params[:name])
    if @topic.update_attributes(topic_params)
      flash[:success] = 'Topic name updated.'
      redirect_to topics_path
    else
      render 'topics/edit'
    end
  end

{'fraction_non_alphanumeric': 0.09111361079865017, 'fraction_numerical': 0.0, 'mean_word_length': 2.8506493506493507, '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': '2959848', 'n_tokens_mistral': 598, 'n_tokens_neox': 579, 'n_words': 141}