Purple-Devs / health_check

Simple health check of Rails app for use with uptime checking sites like newrelic and pingdom
MIT License
476 stars 125 forks source link

Improper loading of ActionController::Base causes initialization conflicts #142

Open ricksuggs opened 8 months ago

ricksuggs commented 8 months ago

Problem

The health_check gem causes ActionController::Base to be loaded too early in the Rails initialization process. This causes some initializers to be loaded after ActionController::Base is loaded, which in turn means that the configurations are not applied as expected.

For example, when a Rails app is upgraded from 6.1 to 7.0, a new_framework_defaults_7_0.rb is created to configure the new framework defaults for the new version one by one. (Source code)

One of these configurations is:

# 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

If the health_check gem is included in the project, then setting this configuration to true has no effect.

This issue is describe in detail in this Github issue in the rails repo.

This section of the Rails documentation describes how to correctly load Rails modules in third party engines / libraries.