<commit_before>class PostsController < ApplicationController
  # TODO (Shimmy): Define logged_in_user
  # before_action :logged_in_user, only: [:create, :destroy]

  def create
    @group = Group.friendly.find(params[:group_id])
    @post = @group.posts.build(post_params)
    @post.user_id = current_user.id
    if @post.save
      flash[:success] = "Post created!"
      redirect_to '/'
    else
      flash[:error] = "Nope"
    end
  end

  def destroy
  end


  private

    # TODO (Shimmy): Add picture support
    def post_params
      params.require(:post).permit(:content, :user_id, :group_id)
    end

    def correct_user
      @post = current_user.post.find_by(id: params[:id])<commit_msg>Fix redirect in create post method<commit_after>class PostsController < ApplicationController
  # TODO (Shimmy): Define logged_in_user
  # before_action :logged_in_user, only: [:create, :destroy]

  def create
    @group = Group.friendly.find(params[:group_id])
    @post = @group.posts.build(post_params)
    @post.user_id = current_user.id
    if @post.save
      redirect_to group_path(@group), notice: "Post has been saved successfully."
    end
  end

  def destroy
  end


  private

    # TODO (Shimmy): Add picture support
    def post_params
      params.require(:post).permit(:content, :user_id, :group_id)
    end

    def correct_user
      @post = current_user.post.find_by(id: params[:id])
{'fraction_non_alphanumeric': 0.1097647897362794, 'fraction_numerical': 0.0, 'mean_word_length': 3.4713375796178343, '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': '802202', 'n_tokens_mistral': 466, 'n_tokens_neox': 451, 'n_words': 107}