From 6bf0c9dc816506f9dd5e13a85a08eb19cc1cdb02 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Thu, 1 Feb 2018 09:26:22 -0500 Subject: [PATCH] Run background actions if winner_id or finished changes --- app/models/match.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/models/match.rb b/app/models/match.rb index 2d5d274..711c680 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -3,14 +3,10 @@ class Match < ActiveRecord::Base belongs_to :weight, touch: true belongs_to :mat, touch: true has_many :wrestlers, :through => :weight + after_update :after_finished_actions, :if => :finished_changed? + after_update :after_finished_actions, :if => :winner_id_changed? - - - after_update do - after_update_actions - end - - def after_update_actions + def after_finished_actions if self.finished == 1 && self.winner_id != nil if self.w1 && self.w2 wrestler1.touch