Browse Source

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

Thorsten Eckel 6 years ago
parent
commit
3d49bf32c8

+ 1 - 1
app/controllers/search_controller.rb

@@ -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

+ 1 - 1
app/models/application_model/can_assets.rb

@@ -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?

+ 1 - 1
app/models/channel.rb

@@ -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

+ 1 - 1
app/models/external_credential.rb

@@ -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
 

+ 1 - 1
config/routes.rb

@@ -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

+ 2 - 2
lib/email_helper/probe.rb

@@ -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

+ 1 - 1
lib/email_helper/verify.rb

@@ -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