From 6fbb3db6f1dda597cc997fa07ab6545ef99f717d Mon Sep 17 00:00:00 2001 From: David Gay Date: Wed, 9 Jun 2021 21:27:36 -0400 Subject: Extra guards to prevent running activity duration check code when important related values are nil (hopefully fixes #3 and fixes #2) --- app/models/character.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/models') diff --git a/app/models/character.rb b/app/models/character.rb index ce2b0db..d386002 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -197,6 +197,7 @@ class Character < ApplicationRecord end def activity_time_remaining + return nil unless self.activity time = activity_duration - (Time.now - self.activity_started_at) time -= rested_duration_to_spend_on_activity if self.rested_duration > 0 time -- cgit v1.2.3