<commit_before>class Admin::PolicyAdvisoryGroupsController < Admin::BaseController
  def index
    @policy_advisory_groups = PolicyAdvisoryGroup.order(:name)
  end

  def new
    @policy_advisory_group = PolicyAdvisoryGroup.new
    build_attachment
  end

  def create
    @policy_advisory_group = PolicyAdvisoryGroup.new(params[:policy_advisory_group])
    if @policy_advisory_group.save
      redirect_to admin_policy_advisory_groups_path, notice: %{"#{@policy_advisory_group.email}" created.}
    else
      render action: "new"
    end
  end

  def edit
    @policy_advisory_group = PolicyAdvisoryGroup.find(params[:id])
    build_attachment
  end

  def update
    @policy_advisory_group = PolicyAdvisoryGroup.find(params[:id])
    if @policy_advisory_group.update_attributes(params[:policy_advisory_group])
      redirect_to admin_policy_advisory_groups_path, notice: %{"#{@policy_advisory_group.email}" saved.}
    else
      render action: "edit"
    end
  end

  private

  def build_attachment
    @policy_advisory_group.build_empty_attachment
  end
end<commit_msg>Handle new attachment replacement params<commit_after>class Admin::PolicyAdvisoryGroupsController < Admin::BaseController
  before_filter :cope_with_attachment_action_params, only: [:update]

  def index
    @policy_advisory_groups = PolicyAdvisoryGroup.order(:name)
  end

  def new
    @policy_advisory_group = PolicyAdvisoryGroup.new
    build_attachment
  end

  def create
    @policy_advisory_group = PolicyAdvisoryGroup.new(params[:policy_advisory_group])
    if @policy_advisory_group.save
      redirect_to admin_policy_advisory_groups_path, notice: %{"#{@policy_advisory_group.email}" created.}
    else
      render action: "new"
    end
  end

  def edit
    @policy_advisory_group = PolicyAdvisoryGroup.find(params[:id])
    build_attachment
  end

  def update
    @policy_advisory_group = PolicyAdvisoryGroup.find(params[:id])
    if @policy_advisory_group.update_attributes(params[:policy_advisory_group])
      redirect_to admin_policy_advisory_groups_path, notice: %{"#{@policy_advisory_group.email}" saved.}
    else
      render action: "edit"
    end
  end

  private

  def build_attachment
    @policy_advisory_group.build_empty_attachment
  end

  def cope_with_attachment_action_params
    return unless params[:policy_advisory_group] && params[:policy_advisory_group][:policy_advisory_group_attachments_attributes]
    params[:policy_advisory_group][:policy_advisory_group_attachments_attributes].each do |_, policy_advisory_group_attachment_params|
      Admin::AttachmentActionParamHandler.manipulate_params!(policy_advisory_group_attachment_params)
    end
  end
end
{'fraction_non_alphanumeric': 0.07528089887640449, 'fraction_numerical': 0.0, 'mean_word_length': 5.226107226107226, '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': '4895596', 'n_tokens_mistral': 863, 'n_tokens_neox': 807, 'n_words': 139}