about summary refs log tree commit diff
path: root/app/controllers/disputes/appeals_controller.rb
blob: eefd92b5a83c708d5329bc4c08088ee9d48c3a86 (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
26
# 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 => e
    @appeal = e.record
    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