<commit_before>class Admin::DispatchesController < AdminController

  def index
    @dispatches = Dispatch.all
  end

  def show
    @dispatch = Dispatch.find(params[:id])
  end

  def create
    @dispatch = Dispatch.new
    @dispatch.save
    redirect_to admin_dispatch_path(@dispatch)
  end

  def update
    @dispatch = Dispatch.find(params[:id])
    @dispatch.update_attributes(params[:dispatch])

    case params[:commit].parameterize
    when "save-test"
      DispatchMailer.delay(
        :queue => :high,
        :retry => false
      ).default_mail(
        @dispatch.id.to_s,
        current_user.id.to_s,
        SecureRandom.hex(4)
      )
      redirect_to admin_dispatch_path(@dispatch)
    when "save-publish"
      redirect_to admin_dispatch_path(@dispatch)
    else
      redirect_to admin_dispatch_path(@dispatch)
    end
  end

end<commit_msg>Secured the dispatches controller.<commit_after>class Admin::DispatchesController < AdminController

  def index
    @dispatches = Dispatch.order_by(:published_at => :desc, :created_at => :desc).all
    authorize @dispatches
  end

  def show
    @dispatch = Dispatch.find(params[:id])
    authorize @dispatch, :show?
  end

  def create
    @dispatch = Dispatch.new

    authorize @dispatch, :create?

    @dispatch.save
    redirect_to admin_dispatch_path(@dispatch)
  end

  def update
    @dispatch = Dispatch.find(params[:id])

    authorize @dispatch, :update?

    @dispatch.update_attributes(params[:dispatch])

    case params[:commit].parameterize
    when "save-test"
      DispatchMailer.delay(
        :queue => :high,
        :retry => false
      ).default_mail(
        @dispatch.id.to_s,
        current_user.id.to_s,
        SecureRandom.hex(4)
      )
      redirect_to admin_dispatch_path(@dispatch)
    when "save-publish"
      redirect_to admin_dispatch_path(@dispatch)
    else
      redirect_to admin_dispatch_path(@dispatch)
    end
  end

end
{'fraction_non_alphanumeric': 0.09937888198757763, 'fraction_numerical': 0.0010351966873706005, 'mean_word_length': 3.0103734439834025, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2948', 'n_tokens_mistral': 608, 'n_tokens_neox': 592, 'n_words': 118}