about summary refs log tree commit diff
path: root/app/controllers/disputes/appeals_controller.rb
blob: 15367c879206172de8f25eb7c7e93d7f962db341 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

class Disputes::AppealsController < Disputes::BaseController
  before_action :set_strike

  def create
    authorize @strike, :appeal?

    @appeal = AppealService.new.call(@strike, appeal_params[:text])

    redirect_to disputes_strike_path(@strike), notice: I18n.t('disputes.strikes.appealed_msg')
  rescue ActiveRecord::RecordInvalid
    render template: 'disputes/strikes/show'
  end

  private

  def set_strike
    @strike = current_account.strikes.find(params[:strike_id])
  end

  def appeal_params
    params.require(:appeal).permit(:text)
  end
end