<commit_before>class PostsController < ApplicationController

  before_filter :authenticate_user!, :except => [:create]

  protect_from_forgery :except => [:create]

  # GET /posts
  # GET /posts.json
  def index
    @posts = Post.all
  end

  # POST /posts
  # POST /posts.json
  def create
    @post = Post.new(post_params)

    params["post"]["reasons"].each do |r|
      reason = Reason.find_or_create_by(reason_name: r)

      @post.reasons << reason
    end

    respond_to do |format|
      if @post.save
        format.html { redirect_to @post, notice: 'Post was successfully created.' }
        format.json { render status: :created, :text => "OK" }
      else
        format.html { render :new }
        format.json { render json: @post.errors, status: :unprocessable_entity }
      end
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_post
      @post = Post.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def post_params
      params.require(:post).permit(:title, :body, :link, :result, :message_link, :message_user, :reasons)
    end
end<commit_msg>adjust json whitelist<commit_after>class PostsController < ApplicationController

  before_filter :authenticate_user!, :except => [:create]

  protect_from_forgery :except => [:create]

  # GET /posts
  # GET /posts.json
  def index
    @posts = Post.all
  end

  # POST /posts
  # POST /posts.json
  def create
    @post = Post.new(post_params)

    params["post"]["reasons"].each do |r|
      reason = Reason.find_or_create_by(reason_name: r)

      @post.reasons << reason
    end

    respond_to do |format|
      if @post.save
        format.html { redirect_to @post, notice: 'Post was successfully created.' }
        format.json { render status: :created, :text => "OK" }
      else
        format.html { render :new }
        format.json { render json: @post.errors, status: :unprocessable_entity }
      end
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_post
      @post = Post.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def post_params
      params.require(:post).permit(:title, :body, :link, :post_creaton_date, :reasons)
    end
end
{'fraction_non_alphanumeric': 0.1049097775912715, 'fraction_numerical': 0.0, 'mean_word_length': 2.8890701468189235, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5610380', 'n_tokens_mistral': 748, 'n_tokens_neox': 720, 'n_words': 215}