<commit_before>class PostsController < ApplicationController
    
    before_action :find_post, only: [:show, :edit, :update, :destroy]
    before_filter :authenticate_user!, except: [:index, :show]
    
    def index
        # if params[:tag]
        #     @posts = Post.tagged_with(params[:tag])
        # else
            if current_user
                @posts = Post.all.order(params[:sort])
            else
                @posts = Post.where(public: true).order(params[:sort])
            end
    end
    
    def show 
    end
    
    def new
        #@post = Post.new
        @post = current_user.posts.build
    end
     
    def edit
        @post = Post.find(params[:id])
        if current_user.id != @post.user_id
            redirect_to post_path(@post)
        end
    end
    
    def update
        if @post.update(post_params)
            redirect_to @post
        else
            render 'new'
        end
    end
    
    def destroy
        @post.destroy
        redirect_to posts_path
    end<commit_msg>ADD: added back tag line in index method<commit_after>class PostsController < ApplicationController
    
    before_action :find_post, only: [:show, :edit, :update, :destroy]
    before_filter :authenticate_user!, except: [:index, :show]
    
    def index
        if params[:tag]
            @posts = Post.tagged_with(params[:tag])
        else
            if current_user
                @posts = Post.all.order(params[:sort])
            else
                @posts = Post.where(public: true).order(params[:sort])
            end
        end
    end
    
    def show 
    end
    
    def new
        #@post = Post.new
        @post = current_user.posts.build
    end
     
    def edit
        @post = Post.find(params[:id])
        if current_user.id != @post.user_id
            redirect_to post_path(@post)
        end
    end
    
    def update
        if @post.update(post_params)
            redirect_to @post
        else
            render 'new'
        end
    end
    
    def destroy
        @post.destroy
        redirect_to posts_path
    end
{'fraction_non_alphanumeric': 0.0880804212541886, 'fraction_numerical': 0.0, 'mean_word_length': 1.5802469135802468, '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': '3499944', 'n_tokens_mistral': 618, 'n_tokens_neox': 603, 'n_words': 147}