Configuring ActiveRecord::Base.include_root_in_json per response is not thread safe
Fixes #30946: Use Rails default for JSON root node
Back when the application had a V1 and V2 API, the V2 API needed to
adhere to the designed format. This included not having a root node
in the JSON output for the object being returned. Given the use of
Rabl was not enforced across the ecosystem of plugins, this was
disabled per request for any request that did not go through the
Rabl rendering engine. The configuration that controls this is a
class variable and is thus not thread safe.
To enable the use of a multi-threaded Puma deployment, this setting
has to be set at application boot and not per request. The previous
implementation returned the setting back to it's default value of
true so that the V1 API was unaffected. This has potential consequences
across other areas of code or plugins that relied on the `to_json`
method on a model to perform further manipulations and were coded
to expect the root.
The alternative approach is to avoid setting this setting all together
and drop it's use. The expectation here would be that all API implementations
should be using Rabl templates properly to follow the API V2 spec
and any plugins relying on attempting to render through to_json
will need to fix this or potentiall encounter a change in their
API responses to have the root node.