Skip to content

Commit

Permalink
Add guards in boot#start
Browse files Browse the repository at this point in the history
  • Loading branch information
zlw committed Dec 28, 2021
1 parent 35d2a5a commit 480d19f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/dry/rails/boot/controller_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
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
Expand Down
7 changes: 5 additions & 2 deletions lib/dry/rails/boot/safe_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
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
Expand Down

0 comments on commit 480d19f

Please sign in to comment.