mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Run background actions if winner_id or finished changes
This commit is contained in:
@@ -3,14 +3,10 @@ class Match < ActiveRecord::Base
|
|||||||
belongs_to :weight, touch: true
|
belongs_to :weight, touch: true
|
||||||
belongs_to :mat, touch: true
|
belongs_to :mat, touch: true
|
||||||
has_many :wrestlers, :through => :weight
|
has_many :wrestlers, :through => :weight
|
||||||
|
after_update :after_finished_actions, :if => :finished_changed?
|
||||||
|
after_update :after_finished_actions, :if => :winner_id_changed?
|
||||||
|
|
||||||
|
def after_finished_actions
|
||||||
|
|
||||||
after_update do
|
|
||||||
after_update_actions
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_update_actions
|
|
||||||
if self.finished == 1 && self.winner_id != nil
|
if self.finished == 1 && self.winner_id != nil
|
||||||
if self.w1 && self.w2
|
if self.w1 && self.w2
|
||||||
wrestler1.touch
|
wrestler1.touch
|
||||||
|
|||||||
Reference in New Issue
Block a user