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 d6a70e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 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,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
Expand Down
6 changes: 4 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,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
Expand Down

0 comments on commit d6a70e9

Please sign in to comment.