From 3dda1ffb632c6c820aa5b468269559c0bd19f89a Mon Sep 17 00:00:00 2001 From: Kevin Yank Date: Mon, 13 Feb 2017 07:08:19 +1100 Subject: [PATCH] Check for agent class file to determine if it's valid (#1907) The previous approach of checking if the class is defined caused problems when the agent class had not yet been loaded by the process. Using Agent.valid_type? instead seems to be the approach that is taken elsewhere in the codebase, and it does not suffer from this problem. --- app/models/agent.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/agent.rb b/app/models/agent.rb index 56ee301c..723f79e3 100644 --- a/app/models/agent.rb +++ b/app/models/agent.rb @@ -418,7 +418,7 @@ class Agent < ActiveRecord::Base return if schedule == 'never' types = where(:schedule => schedule).group(:type).pluck(:type) types.each do |type| - next unless const_defined?(type) + next unless valid_type?(type) type.constantize.bulk_check(schedule) end end