NameError: uninitialized constant #122

This commit is contained in:
Karel Pičman 2019-04-03 14:21:21 +02:00
parent e041519c81
commit df13f8ba8a

View File

@ -56,7 +56,7 @@ class CustomWorkflow < ActiveRecord::Base
def self.run_shared_code(object) def self.run_shared_code(object)
log_message '= Running shared code', object log_message '= Running shared code', object
if CustomWorkflow.table_exists? # Due to DB migration if CustomWorkflow.table_exists? # Due to DB migration
CustomWorkflow.active.where(:observable => :shared).find_each do |workflow| CustomWorkflow.active.where(observable: :shared).find_each do |workflow|
unless workflow.run(object, :shared_code) unless workflow.run(object, :shared_code)
log_message '= Abort running shared code', object log_message '= Abort running shared code', object
return false return false
@ -68,20 +68,22 @@ class CustomWorkflow < ActiveRecord::Base
end end
def self.run_custom_workflows(observable, object, event) def self.run_custom_workflows(observable, object, event)
workflows = CustomWorkflow.active.observing(observable) if CustomWorkflow.table_exists? # Due to DB migration
if PROJECT_OBSERVABLES.include? observable workflows = CustomWorkflow.active.where(observable: observable)
return true unless object.project if PROJECT_OBSERVABLES.include? observable
workflows = workflows.for_project(object.project) return true unless object.project
end workflows = workflows.for_project(object.project)
return true unless workflows.any?
log_message "= Running #{event} custom workflows", object
workflows.each do |workflow|
unless workflow.run(object, event)
log_message "= Abort running #{event} custom workflows", object
return false
end end
return true unless workflows.any?
log_message "= Running #{event} custom workflows", object
workflows.each do |workflow|
unless workflow.run(object, event)
log_message "= Abort running #{event} custom workflows", object
return false
end
end
log_message "= Finished running #{event} custom workflows", object
end end
log_message "= Finished running #{event} custom workflows", object
true true
end end