From b08a0d15c4e990256ba1bf2542b8c01c0640d04c Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Tue, 16 Jun 2020 11:03:47 +0800 Subject: [PATCH] DEV: Fix undefined method due to rails_failover. --- config/initializers/002-rails_failover.rb | 4 ++-- config/initializers/200-first_middlewares.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/initializers/002-rails_failover.rb b/config/initializers/002-rails_failover.rb index 16c5dc4bdaa..a7529a08253 100644 --- a/config/initializers/002-rails_failover.rb +++ b/config/initializers/002-rails_failover.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -return unless Rails.configuration.active_record_rails_failover - if defined?(RailsFailover::Redis) message_bus_keepalive_interval = nil @@ -19,6 +17,8 @@ if defined?(RailsFailover::Redis) end if defined?(RailsFailover::ActiveRecord) + return unless Rails.configuration.active_record_rails_failover + if Rails.configuration.multisite if ActiveRecord::Base.current_role == ActiveRecord::Base.reading_role RailsMultisite::ConnectionManagement.default_connection_handler = diff --git a/config/initializers/200-first_middlewares.rb b/config/initializers/200-first_middlewares.rb index 3f2bce1458a..2467202d6e3 100644 --- a/config/initializers/200-first_middlewares.rb +++ b/config/initializers/200-first_middlewares.rb @@ -25,9 +25,9 @@ if Rails.configuration.multisite Rails.configuration.middleware.unshift RailsMultisite::Middleware, RailsMultisite::DiscoursePatches.config Rails.configuration.middleware.delete ActionDispatch::Executor - if defined?(RailsFailover) && Rails.configuration.active_record_rails_failover + if defined?(RailsFailover::ActiveRecord) && Rails.configuration.active_record_rails_failover Rails.configuration.middleware.insert_after(RailsMultisite::Middleware, RailsFailover::ActiveRecord::Middleware) end -elsif defined?(RailsFailover) && Rails.configuration.active_record_rails_failover +elsif defined?(RailsFailover::ActiveRecord) && Rails.configuration.active_record_rails_failover Rails.configuration.middleware.insert_before(MessageBus::Rack::Middleware, RailsFailover::ActiveRecord::Middleware) end