Skip to content

Commit

Permalink
Use config.load_defaults for rails 7 with 1 override
Browse files Browse the repository at this point in the history
As far as I can see, belongs_to_required_by_default, is the only override in
load_defaults that we manually override.  See:
https://github.com/rails/rails/blob/d437ae311f1b9dc40b442e40eb602e020cec4e49/railties/lib/rails/application/configuration.rb#L92

This change makes the override explicit.

Fixes ManageIQ#23172
  • Loading branch information
jrafanie committed Sep 5, 2024
1 parent 34335f9 commit 30b8e77
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ class Application < Rails::Application

# Disable ActionCable's request forgery protection
# This is basically matching a set of allowed origins which is not good for us
# Note, similarly named forgery protections in action controller are set to true
# https://github.com/rails/rails/blob/d437ae311f1b9dc40b442e40eb602e020cec4e49/railties/lib/rails/application/configuration.rb#L115C12-L115C69
# 5.0 sets: action_controller.forgery_protection_origin_check = true
# 5.2 sets: action_controller.default_protect_from_forgery = true
config.action_cable.disable_request_forgery_protection = false
# Matching the origin against the HOST header is much more convenient
config.action_cable.allow_same_origin_as_host = true
Expand All @@ -110,8 +114,13 @@ class Application < Rails::Application

config.autoload_paths += config.eager_load_paths

# config.load_defaults 6.1
# Disable defaults as ActiveRecord::Base.belongs_to_required_by_default = true causes MiqRegion.seed to fail validation on belongs_to maintenance zone
# FYI, this is where load_defaults is defined as of 7.2:
# https://github.com/rails/rails/blob/d437ae311f1b9dc40b442e40eb602e020cec4e49/railties/lib/rails/application/configuration.rb#L92
config.load_defaults 7.0

# Disable this setting as it causes MiqRegion.seed to fail validation on belongs_to maintenance zone.
# TODO: We should fix this so we don't need to carry this override.
config.active_record.belongs_to_required_by_default = false

# NOTE: If you are going to make changes to autoload_paths, please make
# sure they are all strings. Rails will push these paths into the
Expand Down

0 comments on commit 30b8e77

Please sign in to comment.