Fixed bug: Application is in undefined state while using spring because of usage of 'require' instead of 'require_dependency' to track dependencies.

This commit is contained in:
Thorsten Eckel 2018-10-18 14:22:02 +02:00
parent b538b05209
commit 3d49bf32c8
7 changed files with 8 additions and 8 deletions

View file

@ -66,7 +66,7 @@ class SearchController < ApplicationController
if objects_with_direct_search_index.present?
items = SearchIndexBackend.search(query, limit, objects_with_direct_search_index)
items.each do |item|
require item[:type].to_filename
require_dependency item[:type].to_filename
local_class = Kernel.const_get(item[:type])
record = local_class.lookup(id: item[:id])
next if !record

View file

@ -144,7 +144,7 @@ get assets of object list
def assets_of_object_list(list, assets = {})
list.each do |item|
require item['object'].to_filename
require_dependency item['object'].to_filename
record = Kernel.const_get(item['object']).find(item['o_id'])
assets = record.assets(assets)
if item['created_by_id'].present?

View file

@ -318,7 +318,7 @@ load channel driver and return class
# 'warning: toplevel constant Twitter referenced by Channel::Driver::Twitter' error e.g.
# so we have to convert the channel name to the filename via Rails String.underscore
# http://stem.ps/rails/2015/01/25/ruby-gotcha-toplevel-constant-referenced-by.html
require "channel/driver/#{adapter.to_filename}"
require_dependency "channel/driver/#{adapter.to_filename}"
Object.const_get("::Channel::Driver::#{adapter.to_classname}")
end

View file

@ -29,7 +29,7 @@ class ExternalCredential < ApplicationModel
def self.load_backend(provider)
adapter = "ExternalCredential::#{provider.camelcase}"
require adapter.to_filename.to_s
require_dependency adapter.to_filename.to_s
load_adapter(adapter)
end

View file

@ -12,7 +12,7 @@ Rails.application.routes.draw do
files = Dir.glob( "#{dir}/routes/*.rb" )
files.each do |file|
if Rails.configuration.cache_classes
require file
require_dependency file
else
load file
end

View file

@ -221,7 +221,7 @@ returns on fail
# connection test
result_inbound = {}
begin
require "channel/driver/#{adapter.to_filename}"
require_dependency "channel/driver/#{adapter.to_filename}"
driver_class = Object.const_get("Channel::Driver::#{adapter.to_classname}")
driver_instance = driver_class.new
@ -319,7 +319,7 @@ returns on fail
# test connection
begin
require "channel/driver/#{adapter.to_filename}"
require_dependency "channel/driver/#{adapter.to_filename}"
driver_class = Object.const_get("Channel::Driver::#{adapter.to_classname}")
driver_instance = driver_class.new

View file

@ -80,7 +80,7 @@ or
fetch_result = nil
begin
require "channel/driver/#{adapter.to_filename}"
require_dependency "channel/driver/#{adapter.to_filename}"
driver_class = Object.const_get("Channel::Driver::#{adapter.to_classname}")
driver_instance = driver_class.new