@appeal = AppealService.new.call(@strike, appeal_params[:text])
redirect_to disputes_strike_path(@strike), notice: I18n.t('disputes.strikes.appealed_msg')
- rescue ActiveRecord::RecordInvalid
+ rescue ActiveRecord::RecordInvalid => e
+ @appeal = e.record
render template: 'disputes/strikes/show'
end
# updated_at :datetime not null
#
class Appeal < ApplicationRecord
+ MAX_STRIKE_AGE = 20.days
+
belongs_to :account
belongs_to :strike, class_name: 'AccountWarning', foreign_key: 'account_warning_id'
belongs_to :approved_by_account, class_name: 'Account', optional: true
private
def validate_time_frame
- errors.add(:base, I18n.t('strikes.errors.too_late')) if Time.now.utc > (strike.created_at + 20.days)
+ errors.add(:base, I18n.t('strikes.errors.too_late')) if strike.created_at < MAX_STRIKE_AGE.ago
end
end