docbrown/config/initializers/wrap_parameters.rb
rhymes 5e9be0c32d
Disable ActionController auto params wrapping (#11692)
* Disable ActionController auto params wrapping

Rails by default accepts wrapped and unwrapped parameters in JSON requests (with or without a root object), regardless of the fact that the contract with the client requests wrapped parameters or not. This results in unforeseeable bugs when the client sends unwrapped parameters in lieu of wrapped ones.

As undeterministic bugs are a PITA and this is the classic grey area in Rails apps and as the customer facing API is fully documented and the internal can be manually adjusted, we disable this and be done with this odd feature.

https://github.com/forem/forem/issues/11645
https://github.com/forem/forem/pull/11638

* Remove accidentally committed file
2020-12-02 15:17:43 +01:00

16 lines
636 B
Ruby

# 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
# Globally disable auto wrapping resulting in a stricter API and to avoid bugs with array payloads.
# See <https://github.com/forem/forem/issues/11645>
wrap_parameters format: []
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end