From d64d1ea31f09af04886bd1fb3fcce05f6865cf95 Mon Sep 17 00:00:00 2001 From: zlw Date: Tue, 28 Dec 2021 15:54:52 +0100 Subject: [PATCH] Add guards in boot#start --- lib/dry/rails/boot/controller_helpers.rb | 6 ++++-- lib/dry/rails/boot/safe_params.rb | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/dry/rails/boot/controller_helpers.rb b/lib/dry/rails/boot/controller_helpers.rb index 895c1e0..7685862 100644 --- a/lib/dry/rails/boot/controller_helpers.rb +++ b/lib/dry/rails/boot/controller_helpers.rb @@ -6,9 +6,11 @@ end start do - ApplicationController.include(Dry::Rails::Features::ControllerHelpers) + unless ApplicationController.include?(Dry::Rails::Features::ControllerHelpers) + ApplicationController.include(Dry::Rails::Features::ControllerHelpers) + end - if defined?(ActionController::API) + if defined?(ActionController::API) && !ActionController::API.include?(Dry::Rails::Features::ControllerHelpers) ActionController::API.include(Dry::Rails::Features::ControllerHelpers) end end diff --git a/lib/dry/rails/boot/safe_params.rb b/lib/dry/rails/boot/safe_params.rb index 4fd21c2..de7ae26 100644 --- a/lib/dry/rails/boot/safe_params.rb +++ b/lib/dry/rails/boot/safe_params.rb @@ -6,9 +6,11 @@ end start do - ActionController::Base.include(Dry::Rails::Features::SafeParams) + unless ActionController::Base.include?(Dry::Rails::Features::SafeParams) + ActionController::Base.include(Dry::Rails::Features::SafeParams) + end - if defined?(ActionController::API) + if defined?(ActionController::API) && ! ActionController::API.include?(Dry::Rails::Features::SafeParams) ActionController::API.include(Dry::Rails::Features::SafeParams) end end