<commit_before>class ArticlesController < ApplicationController

    def index
        @articles = Article.all
    end

    def new
        @article = Article.new
    end

    def edit
        @article = Article.find(params[:id])
    end

    def create
        @article = Article.new(article_params)
        if @article.save
            flash[:notice] = "Article was succcessfully created"
            redirect_to article_path(@article)
        else
            render 'new'
        end
    end

    def show
        @article = Article.find(params[:id])
    end

    def destroy
        @article = Article.find(params[:id])
        @article.destroy
        flash[:notice] = "Article was of destroy"
        redirect_to articles_path
    end

    def update
        @article = Article.find(params[:id])
        if @article.update(article_params)
            flash[:notice] = "Article was succcessfully updated"
            redirect_to article_path(@article)
        else
            render 'edit'
        end
    end

    private
    def article_params
        params.require(:article).permit(:title, :description)
    end

end<commit_msg>Extract redundancy and prepare for prod<commit_after>class ArticlesController < ApplicationController
    before_action :set_article, only: [:edit, :update, :show, :destroy]

    def index
        @articles = Article.all
    end

    def new
        @article = Article.new
    end

    def edit
    end

    def create
        @article = Article.new(article_params)
        if @article.save
            flash[:notice] = "Article was succcessfully created"
            redirect_to article_path(@article)
        else
            render 'new'
        end
    end

    def show
    end

    def destroy
        @article.destroy
        flash[:notice] = "Article was of destroy"
        redirect_to articles_path
    end

    def update
        if @article.update(article_params)
            flash[:notice] = "Article was succcessfully updated"
            redirect_to article_path(@article)
        else
            render 'edit'
        end
    end

    private
    def set_article
        @article = Article.find(params[:id])
    end

    def article_params
        params.require(:article).permit(:title, :description)
    end

end
{'fraction_non_alphanumeric': 0.07665198237885462, 'fraction_numerical': 0.0, 'mean_word_length': 1.968627450980392, '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': '1442510', 'n_tokens_mistral': 624, 'n_tokens_neox': 595, 'n_words': 166}