From e1e5efe34b869f0166d6dca3786ee5342f73fb8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 28 Mar 2024 03:08:33 +0100 Subject: [PATCH] Wrap parameters by default in ActionController As mentioned in the Rails configuration documentation [1] (note the link points to the configuration guide for Rails 7.1, but only because the documentation for this option wasn't as good in the configuration guide for Rails 7.0; the behavior hasn't changed between these two versions), this was done in the `wrap_parameters` initializer but now it can be done using a new default configuration option. [1] https://guides.rubyonrails.org/v7.1/configuring.html#config-action-controller-wrap-parameters-by-default --- config/initializers/new_framework_defaults_7_0.rb | 2 +- config/initializers/wrap_parameters.rb | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 config/initializers/wrap_parameters.rb diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb index 343c33ced..aa3bfb5bc 100644 --- a/config/initializers/new_framework_defaults_7_0.rb +++ b/config/initializers/new_framework_defaults_7_0.rb @@ -73,7 +73,7 @@ Rails.application.config.action_controller.raise_on_open_redirects = true # Enable parameter wrapping for JSON. # Previously this was set in an initializer. It's fine to keep using that initializer if you've customized it. # To disable parameter wrapping entirely, set this config to `false`. -# Rails.application.config.action_controller.wrap_parameters_by_default = true +Rails.application.config.action_controller.wrap_parameters_by_default = true # Specifies whether generated namespaced UUIDs follow the RFC 4122 standard for namespace IDs provided as a # `String` to `Digest::UUID.uuid_v3` or `Digest::UUID.uuid_v5` method calls. diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb deleted file mode 100644 index bbfc3961b..000000000 --- a/config/initializers/wrap_parameters.rb +++ /dev/null @@ -1,14 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# This file contains settings for ActionController::ParamsWrapper which -# is enabled by default. - -# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. -ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [:json] -end - -# To enable root element in JSON for ActiveRecord objects. -# ActiveSupport.on_load(:active_record) do -# self.include_root_in_json = true -# end