railties 7.0.8.7 → 7.2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +210 -272
- data/MIT-LICENSE +1 -1
- data/RDOC_MAIN.md +99 -0
- data/README.rdoc +4 -4
- data/lib/minitest/rails_plugin.rb +67 -1
- data/lib/rails/all.rb +1 -3
- data/lib/rails/api/task.rb +39 -6
- data/lib/rails/application/bootstrap.rb +28 -10
- data/lib/rails/application/configuration.rb +228 -72
- data/lib/rails/application/default_middleware_stack.rb +8 -2
- data/lib/rails/application/dummy_config.rb +19 -0
- data/lib/rails/application/finisher.rb +50 -33
- data/lib/rails/application.rb +117 -76
- data/lib/rails/backtrace_cleaner.rb +19 -4
- data/lib/rails/cli.rb +5 -3
- data/lib/rails/command/actions.rb +10 -12
- data/lib/rails/command/base.rb +55 -53
- data/lib/rails/command/environment_argument.rb +32 -16
- data/lib/rails/command/helpers/editor.rb +17 -12
- data/lib/rails/command.rb +84 -33
- data/lib/rails/commands/about/about_command.rb +14 -0
- data/lib/rails/commands/app/update_command.rb +102 -0
- data/lib/rails/commands/application/application_command.rb +2 -0
- data/lib/rails/commands/boot/boot_command.rb +14 -0
- data/lib/rails/commands/console/console_command.rb +11 -30
- data/lib/rails/commands/console/irb_console.rb +146 -0
- data/lib/rails/commands/credentials/USAGE +53 -55
- data/lib/rails/commands/credentials/credentials_command/diffing.rb +5 -3
- data/lib/rails/commands/credentials/credentials_command.rb +64 -70
- data/lib/rails/commands/db/system/change/change_command.rb +2 -1
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +32 -131
- data/lib/rails/commands/destroy/destroy_command.rb +3 -2
- data/lib/rails/commands/dev/dev_command.rb +1 -6
- data/lib/rails/commands/devcontainer/devcontainer_command.rb +39 -0
- data/lib/rails/commands/encrypted/USAGE +15 -20
- data/lib/rails/commands/encrypted/encrypted_command.rb +46 -35
- data/lib/rails/commands/gem_help/USAGE +16 -0
- data/lib/rails/commands/gem_help/gem_help_command.rb +13 -0
- data/lib/rails/commands/generate/generate_command.rb +2 -2
- data/lib/rails/commands/help/USAGE +13 -13
- data/lib/rails/commands/help/help_command.rb +21 -2
- data/lib/rails/commands/initializers/initializers_command.rb +1 -4
- data/lib/rails/commands/middleware/middleware_command.rb +17 -0
- data/lib/rails/commands/new/new_command.rb +2 -0
- data/lib/rails/commands/notes/notes_command.rb +2 -1
- data/lib/rails/commands/plugin/plugin_command.rb +2 -0
- data/lib/rails/commands/rake/rake_command.rb +25 -22
- data/lib/rails/commands/restart/restart_command.rb +14 -0
- data/lib/rails/commands/routes/routes_command.rb +13 -1
- data/lib/rails/commands/runner/USAGE +14 -12
- data/lib/rails/commands/runner/runner_command.rb +42 -19
- data/lib/rails/commands/secret/secret_command.rb +13 -0
- data/lib/rails/commands/server/server_command.rb +37 -34
- data/lib/rails/commands/test/USAGE +14 -0
- data/lib/rails/commands/test/test_command.rb +58 -14
- data/lib/rails/commands/unused_routes/unused_routes_command.rb +75 -0
- data/lib/rails/commands/version/version_command.rb +1 -0
- data/lib/rails/configuration.rb +15 -6
- data/lib/rails/console/app.rb +5 -35
- data/lib/rails/console/helpers.rb +5 -16
- data/lib/rails/console/methods.rb +23 -0
- data/lib/rails/deprecator.rb +7 -0
- data/lib/rails/engine/configuration.rb +50 -6
- data/lib/rails/engine.rb +53 -25
- data/lib/rails/gem_version.rb +4 -4
- data/lib/rails/generators/actions.rb +6 -15
- data/lib/rails/generators/active_model.rb +28 -14
- data/lib/rails/generators/app_base.rb +382 -88
- data/lib/rails/generators/app_name.rb +3 -14
- data/lib/rails/generators/base.rb +21 -9
- data/lib/rails/generators/database.rb +231 -35
- data/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt +1 -1
- data/lib/rails/generators/erb/scaffold/templates/edit.html.erb.tt +2 -0
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +2 -0
- data/lib/rails/generators/erb/scaffold/templates/new.html.erb.tt +2 -0
- data/lib/rails/generators/generated_attribute.rb +38 -1
- data/lib/rails/generators/migration.rb +4 -5
- data/lib/rails/generators/model_helpers.rb +2 -1
- data/lib/rails/generators/rails/app/USAGE +22 -6
- data/lib/rails/generators/rails/app/app_generator.rb +135 -86
- data/lib/rails/generators/rails/app/templates/Dockerfile.tt +110 -0
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +19 -21
- data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +4 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +8 -1
- data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/app/views/pwa/manifest.json.erb.tt +22 -0
- data/lib/rails/generators/rails/app/templates/app/views/pwa/service-worker.js +26 -0
- data/lib/rails/generators/rails/app/templates/bin/brakeman.tt +6 -0
- data/lib/rails/generators/rails/app/templates/bin/rubocop.tt +7 -0
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +15 -2
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +6 -17
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +11 -6
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +10 -3
- data/lib/rails/generators/rails/app/templates/config/databases/{jdbcmysql.yml.tt → trilogy.yml.tt} +12 -7
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +25 -8
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +40 -28
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +20 -13
- data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +3 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +4 -4
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_2.rb.tt +70 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +11 -9
- data/lib/rails/generators/rails/app/templates/config/locales/en.yml +11 -13
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +25 -34
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +11 -1
- data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +6 -4
- data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +15 -0
- data/lib/rails/generators/rails/app/templates/dockerignore.tt +56 -0
- data/lib/rails/generators/rails/app/templates/github/ci.yml.tt +138 -0
- data/lib/rails/generators/rails/app/templates/github/dependabot.yml +12 -0
- data/lib/rails/generators/rails/app/templates/gitignore.tt +7 -11
- data/lib/rails/generators/rails/app/templates/node-version.tt +1 -0
- data/lib/rails/generators/rails/app/templates/public/406-unsupported-browser.html +66 -0
- data/lib/rails/generators/rails/app/templates/public/icon.png +0 -0
- data/lib/rails/generators/rails/app/templates/public/icon.svg +3 -0
- data/lib/rails/generators/rails/app/templates/rubocop.yml.tt +8 -0
- data/lib/rails/generators/rails/app/templates/test/application_system_test_case.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +10 -8
- data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +9 -7
- data/lib/rails/generators/rails/application_record/application_record_generator.rb +4 -0
- data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +2 -1
- data/lib/rails/generators/rails/controller/USAGE +12 -4
- data/lib/rails/generators/rails/controller/controller_generator.rb +6 -1
- data/lib/rails/generators/rails/controller/templates/controller.rb.tt +1 -1
- data/lib/rails/generators/rails/credentials/credentials_generator.rb +29 -24
- data/lib/rails/generators/rails/credentials/templates/credentials.yml.tt +8 -0
- data/lib/rails/generators/rails/db/system/change/change_generator.rb +146 -5
- data/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb +166 -0
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/Dockerfile.tt +3 -0
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/compose.yaml.tt +47 -0
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/devcontainer.json.tt +37 -0
- data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +1 -2
- data/lib/rails/generators/rails/migration/USAGE +21 -11
- data/lib/rails/generators/rails/migration/migration_generator.rb +4 -0
- data/lib/rails/generators/rails/model/model_generator.rb +4 -0
- data/lib/rails/generators/rails/plugin/USAGE +17 -6
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +45 -22
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +2 -2
- data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +7 -3
- data/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +2 -0
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +1 -17
- data/lib/rails/generators/rails/plugin/templates/bin/rubocop.tt +7 -0
- data/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt +103 -0
- data/lib/rails/generators/rails/plugin/templates/github/dependabot.yml +12 -0
- data/lib/rails/generators/rails/plugin/templates/gitignore.tt +0 -2
- data/lib/rails/generators/rails/plugin/templates/rubocop.yml.tt +8 -0
- data/lib/rails/generators/rails/plugin/templates/test/application_system_test_case.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +5 -5
- data/lib/rails/generators/rails/resource/resource_generator.rb +6 -0
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -1
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +1 -1
- data/lib/rails/generators/test_case.rb +2 -2
- data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt +6 -4
- data/lib/rails/generators/test_unit/mailer/templates/preview.rb.tt +3 -2
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +16 -2
- data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +2 -2
- data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +2 -2
- data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +2 -0
- data/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb.tt +1 -1
- data/lib/rails/generators/testing/assertions.rb +20 -0
- data/lib/rails/generators/testing/{behaviour.rb → behavior.rb} +8 -4
- data/lib/rails/generators.rb +12 -16
- data/lib/rails/health_controller.rb +55 -0
- data/lib/rails/info.rb +3 -3
- data/lib/rails/info_controller.rb +33 -11
- data/lib/rails/mailers_controller.rb +29 -6
- data/lib/rails/paths.rb +15 -12
- data/lib/rails/pwa_controller.rb +15 -0
- data/lib/rails/rack/logger.rb +27 -16
- data/lib/rails/rackup/server.rb +15 -0
- data/lib/rails/railtie/configurable.rb +2 -2
- data/lib/rails/railtie/configuration.rb +14 -1
- data/lib/rails/railtie.rb +33 -34
- data/lib/rails/source_annotation_extractor.rb +67 -18
- data/lib/rails/tasks/engine.rake +8 -8
- data/lib/rails/tasks/framework.rake +2 -34
- data/lib/rails/tasks/log.rake +1 -1
- data/lib/rails/tasks/misc.rake +3 -14
- data/lib/rails/tasks/statistics.rake +5 -4
- data/lib/rails/tasks/tmp.rake +6 -6
- data/lib/rails/tasks/zeitwerk.rake +15 -35
- data/lib/rails/tasks.rb +0 -2
- data/lib/rails/templates/layouts/application.html.erb +1 -1
- data/lib/rails/templates/rails/mailers/email.html.erb +44 -8
- data/lib/rails/templates/rails/mailers/index.html.erb +14 -7
- data/lib/rails/templates/rails/mailers/mailer.html.erb +11 -5
- data/lib/rails/templates/rails/welcome/index.html.erb +5 -2
- data/lib/rails/test_help.rb +11 -18
- data/lib/rails/test_unit/line_filtering.rb +1 -1
- data/lib/rails/test_unit/reporter.rb +14 -4
- data/lib/rails/test_unit/runner.rb +62 -20
- data/lib/rails/test_unit/test_parser.rb +133 -0
- data/lib/rails/test_unit/testing.rake +13 -33
- data/lib/rails/testing/maintain_test_schema.rb +16 -0
- data/lib/rails/version.rb +1 -1
- data/lib/rails/zeitwerk_checker.rb +15 -0
- data/lib/rails.rb +20 -17
- metadata +87 -40
- data/RDOC_MAIN.rdoc +0 -97
- data/lib/rails/app_updater.rb +0 -40
- data/lib/rails/application/dummy_erb_compiler.rb +0 -18
- data/lib/rails/commands/secrets/USAGE +0 -66
- data/lib/rails/commands/secrets/secrets_command.rb +0 -65
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +0 -68
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +0 -70
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +0 -24
- data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +0 -62
- data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +0 -53
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_0.rb.tt +0 -143
- data/lib/rails/generators/rails/app/templates/public/apple-touch-icon-precomposed.png +0 -0
- data/lib/rails/generators/rails/app/templates/public/apple-touch-icon.png +0 -0
- data/lib/rails/generators/rails/app/templates/public/favicon.ico +0 -0
- data/lib/rails/generators/rails/model/USAGE +0 -113
- data/lib/rails/ruby_version_check.rb +0 -15
- data/lib/rails/secrets.rb +0 -110
- data/lib/rails/tasks/middleware.rake +0 -9
- data/lib/rails/tasks/restart.rake +0 -9
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "ipaddr"
|
4
|
+
require "active_support/core_ext/array/wrap"
|
4
5
|
require "active_support/core_ext/kernel/reporting"
|
5
6
|
require "active_support/file_update_checker"
|
6
7
|
require "active_support/configuration_file"
|
@@ -10,20 +11,21 @@ require "rails/source_annotation_extractor"
|
|
10
11
|
module Rails
|
11
12
|
class Application
|
12
13
|
class Configuration < ::Rails::Engine::Configuration
|
13
|
-
attr_accessor :allow_concurrency, :asset_host, :autoflush_log,
|
14
|
+
attr_accessor :allow_concurrency, :asset_host, :assume_ssl, :autoflush_log,
|
14
15
|
:cache_classes, :cache_store, :consider_all_requests_local, :console,
|
15
|
-
:eager_load, :exceptions_app, :file_watcher, :filter_parameters,
|
16
|
+
:eager_load, :exceptions_app, :file_watcher, :filter_parameters, :precompile_filter_parameters,
|
16
17
|
:force_ssl, :helpers_paths, :hosts, :host_authorization, :logger, :log_formatter,
|
17
|
-
:log_tags, :railties_order, :relative_url_root,
|
18
|
+
:log_tags, :railties_order, :relative_url_root,
|
18
19
|
:ssl_options, :public_file_server,
|
19
20
|
:session_options, :time_zone, :reload_classes_only_on_change,
|
20
|
-
:beginning_of_week, :filter_redirect, :x,
|
21
|
-
:
|
21
|
+
:beginning_of_week, :filter_redirect, :x,
|
22
|
+
:content_security_policy_report_only,
|
22
23
|
:content_security_policy_nonce_generator, :content_security_policy_nonce_directives,
|
23
|
-
:require_master_key, :credentials, :disable_sandbox, :
|
24
|
-
:rake_eager_load, :server_timing
|
24
|
+
:require_master_key, :credentials, :disable_sandbox, :sandbox_by_default,
|
25
|
+
:add_autoload_paths_to_load_path, :rake_eager_load, :server_timing, :log_file_size,
|
26
|
+
:dom_testing_default_html_version, :yjit
|
25
27
|
|
26
|
-
attr_reader :encoding, :api_only, :loaded_config_version
|
28
|
+
attr_reader :encoding, :api_only, :loaded_config_version, :log_level
|
27
29
|
|
28
30
|
def initialize(*)
|
29
31
|
super
|
@@ -43,12 +45,14 @@ module Rails
|
|
43
45
|
@public_file_server = ActiveSupport::OrderedOptions.new
|
44
46
|
@public_file_server.enabled = true
|
45
47
|
@public_file_server.index_name = "index"
|
48
|
+
@assume_ssl = false
|
46
49
|
@force_ssl = false
|
47
50
|
@ssl_options = {}
|
48
51
|
@session_store = nil
|
49
52
|
@time_zone = "UTC"
|
50
53
|
@beginning_of_week = :monday
|
51
54
|
@log_level = :debug
|
55
|
+
@log_file_size = nil
|
52
56
|
@generators = app_generators
|
53
57
|
@cache_store = [ :file_store, "#{root}/tmp/cache/" ]
|
54
58
|
@railties_order = [:all]
|
@@ -63,35 +67,51 @@ module Rails
|
|
63
67
|
@api_only = false
|
64
68
|
@debug_exception_response_format = nil
|
65
69
|
@x = Custom.new
|
66
|
-
@enable_dependency_loading = false
|
67
|
-
@read_encrypted_secrets = false
|
68
70
|
@content_security_policy = nil
|
69
71
|
@content_security_policy_report_only = false
|
70
72
|
@content_security_policy_nonce_generator = nil
|
71
73
|
@content_security_policy_nonce_directives = nil
|
72
74
|
@require_master_key = false
|
73
75
|
@loaded_config_version = nil
|
74
|
-
@credentials = ActiveSupport::
|
75
|
-
@credentials.content_path = default_credentials_content_path
|
76
|
-
@credentials.key_path = default_credentials_key_path
|
76
|
+
@credentials = ActiveSupport::InheritableOptions.new(credentials_defaults)
|
77
77
|
@disable_sandbox = false
|
78
|
+
@sandbox_by_default = false
|
78
79
|
@add_autoload_paths_to_load_path = true
|
79
80
|
@permissions_policy = nil
|
80
81
|
@rake_eager_load = false
|
81
82
|
@server_timing = false
|
83
|
+
@dom_testing_default_html_version = :html4
|
84
|
+
@yjit = false
|
82
85
|
end
|
83
86
|
|
84
87
|
# Loads default configuration values for a target version. This includes
|
85
88
|
# defaults for versions prior to the target version. See the
|
86
|
-
# {configuration guide}[https://guides.rubyonrails.org/configuring.html]
|
89
|
+
# {configuration guide}[https://guides.rubyonrails.org/configuring.html#versioned-default-values]
|
87
90
|
# for the default values associated with a particular version.
|
88
91
|
def load_defaults(target_version)
|
92
|
+
# To introduce a change in behavior, follow these steps:
|
93
|
+
# 1. Add an accessor on the target object (e.g. the ActiveJob class for
|
94
|
+
# global Active Job config).
|
95
|
+
# 2. Set a default value there preserving existing behavior for existing
|
96
|
+
# applications.
|
97
|
+
# 3. Implement the behavior change based on the config value.
|
98
|
+
# 4. In the section below corresponding to the next release of Rails,
|
99
|
+
# configure the default value.
|
100
|
+
# 5. Add a commented out section in the `new_framework_defaults` to
|
101
|
+
# configure the default value again.
|
102
|
+
# 6. Update the guide in `configuring.md`.
|
103
|
+
|
104
|
+
# To remove configurable deprecated behavior, follow these steps:
|
105
|
+
# 1. Update or remove the entry in the guides.
|
106
|
+
# 2. Remove the references below.
|
107
|
+
# 3. Remove the legacy code paths and config check.
|
108
|
+
# 4. Remove the config accessor.
|
109
|
+
|
89
110
|
case target_version.to_s
|
90
111
|
when "5.0"
|
91
112
|
if respond_to?(:action_controller)
|
92
113
|
action_controller.per_form_csrf_tokens = true
|
93
114
|
action_controller.forgery_protection_origin_check = true
|
94
|
-
action_controller.urlsafe_csrf_tokens = false
|
95
115
|
end
|
96
116
|
|
97
117
|
ActiveSupport.to_time_preserves_timezone = true
|
@@ -152,8 +172,6 @@ module Rails
|
|
152
172
|
if respond_to?(:active_storage)
|
153
173
|
active_storage.queues.analysis = :active_storage_analysis
|
154
174
|
active_storage.queues.purge = :active_storage_purge
|
155
|
-
|
156
|
-
active_storage.replace_on_assign_to_many = true
|
157
175
|
end
|
158
176
|
|
159
177
|
if respond_to?(:active_record)
|
@@ -164,7 +182,6 @@ module Rails
|
|
164
182
|
|
165
183
|
if respond_to?(:active_record)
|
166
184
|
active_record.has_many_inversing = true
|
167
|
-
active_record.legacy_connection_handling = false
|
168
185
|
end
|
169
186
|
|
170
187
|
if respond_to?(:active_job)
|
@@ -176,10 +193,6 @@ module Rails
|
|
176
193
|
action_dispatch.ssl_default_redirect_status = 308
|
177
194
|
end
|
178
195
|
|
179
|
-
if respond_to?(:action_controller)
|
180
|
-
action_controller.delete(:urlsafe_csrf_tokens)
|
181
|
-
end
|
182
|
-
|
183
196
|
if respond_to?(:action_view)
|
184
197
|
action_view.form_with_generates_remote_forms = false
|
185
198
|
action_view.preload_links_header = true
|
@@ -214,7 +227,6 @@ module Rails
|
|
214
227
|
"X-Permitted-Cross-Domain-Policies" => "none",
|
215
228
|
"Referrer-Policy" => "strict-origin-when-cross-origin"
|
216
229
|
}
|
217
|
-
action_dispatch.return_only_request_media_type_on_content_type = false
|
218
230
|
action_dispatch.cookies_serializer = :json
|
219
231
|
end
|
220
232
|
|
@@ -226,11 +238,8 @@ module Rails
|
|
226
238
|
if respond_to?(:active_support)
|
227
239
|
active_support.hash_digest_class = OpenSSL::Digest::SHA256
|
228
240
|
active_support.key_generator_hash_digest_class = OpenSSL::Digest::SHA256
|
229
|
-
active_support.remove_deprecated_time_with_zone_name = true
|
230
241
|
active_support.cache_format_version = 7.0
|
231
|
-
active_support.use_rfc4122_namespaced_uuids = true
|
232
242
|
active_support.executor_around_test_case = true
|
233
|
-
active_support.disable_to_s_conversion = true
|
234
243
|
end
|
235
244
|
|
236
245
|
if respond_to?(:action_mailer)
|
@@ -254,9 +263,78 @@ module Rails
|
|
254
263
|
|
255
264
|
if respond_to?(:action_controller)
|
256
265
|
action_controller.raise_on_open_redirects = true
|
257
|
-
|
258
266
|
action_controller.wrap_parameters_by_default = true
|
259
267
|
end
|
268
|
+
when "7.1"
|
269
|
+
load_defaults "7.0"
|
270
|
+
|
271
|
+
self.add_autoload_paths_to_load_path = false
|
272
|
+
self.precompile_filter_parameters = true
|
273
|
+
self.dom_testing_default_html_version = defined?(Nokogiri::HTML5) ? :html5 : :html4
|
274
|
+
|
275
|
+
if Rails.env.local?
|
276
|
+
self.log_file_size = 100 * 1024 * 1024
|
277
|
+
end
|
278
|
+
|
279
|
+
if respond_to?(:active_record)
|
280
|
+
active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false
|
281
|
+
active_record.sqlite3_adapter_strict_strings_by_default = true
|
282
|
+
active_record.query_log_tags_format = :sqlcommenter
|
283
|
+
active_record.raise_on_assign_to_attr_readonly = true
|
284
|
+
active_record.belongs_to_required_validates_foreign_key = false
|
285
|
+
active_record.before_committed_on_all_records = true
|
286
|
+
active_record.default_column_serializer = nil
|
287
|
+
active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA256
|
288
|
+
active_record.encryption.support_sha1_for_non_deterministic_encryption = false
|
289
|
+
active_record.marshalling_format_version = 7.1
|
290
|
+
active_record.run_after_transaction_callbacks_in_order_defined = true
|
291
|
+
active_record.generate_secure_token_on = :initialize
|
292
|
+
end
|
293
|
+
|
294
|
+
if respond_to?(:action_dispatch)
|
295
|
+
action_dispatch.default_headers = {
|
296
|
+
"X-Frame-Options" => "SAMEORIGIN",
|
297
|
+
"X-XSS-Protection" => "0",
|
298
|
+
"X-Content-Type-Options" => "nosniff",
|
299
|
+
"X-Permitted-Cross-Domain-Policies" => "none",
|
300
|
+
"Referrer-Policy" => "strict-origin-when-cross-origin"
|
301
|
+
}
|
302
|
+
action_dispatch.debug_exception_log_level = :error
|
303
|
+
end
|
304
|
+
|
305
|
+
if respond_to?(:active_support)
|
306
|
+
active_support.cache_format_version = 7.1
|
307
|
+
active_support.message_serializer = :json_allow_marshal
|
308
|
+
active_support.use_message_serializer_for_metadata = true
|
309
|
+
active_support.raise_on_invalid_cache_expiration_time = true
|
310
|
+
end
|
311
|
+
|
312
|
+
if respond_to?(:action_view)
|
313
|
+
require "action_view/helpers"
|
314
|
+
action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
|
315
|
+
end
|
316
|
+
|
317
|
+
if respond_to?(:action_text)
|
318
|
+
require "action_view/helpers"
|
319
|
+
action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
|
320
|
+
end
|
321
|
+
when "7.2"
|
322
|
+
load_defaults "7.1"
|
323
|
+
|
324
|
+
self.yjit = true
|
325
|
+
|
326
|
+
if respond_to?(:active_job)
|
327
|
+
active_job.enqueue_after_transaction_commit = :default
|
328
|
+
end
|
329
|
+
|
330
|
+
if respond_to?(:active_storage)
|
331
|
+
active_storage.web_image_content_types = %w( image/png image/jpeg image/gif image/webp )
|
332
|
+
end
|
333
|
+
|
334
|
+
if respond_to?(:active_record)
|
335
|
+
active_record.postgresql_adapter_decode_dates = true
|
336
|
+
active_record.validate_migration_timestamps = true
|
337
|
+
end
|
260
338
|
else
|
261
339
|
raise "Unknown version #{target_version.to_s.inspect}"
|
262
340
|
end
|
@@ -264,6 +342,26 @@ module Rails
|
|
264
342
|
@loaded_config_version = target_version
|
265
343
|
end
|
266
344
|
|
345
|
+
def reloading_enabled?
|
346
|
+
enable_reloading
|
347
|
+
end
|
348
|
+
|
349
|
+
def enable_reloading
|
350
|
+
!cache_classes
|
351
|
+
end
|
352
|
+
|
353
|
+
def enable_reloading=(value)
|
354
|
+
self.cache_classes = !value
|
355
|
+
end
|
356
|
+
|
357
|
+
def read_encrypted_secrets
|
358
|
+
Rails.deprecator.warn("'config.read_encrypted_secrets' is deprecated and will be removed in Rails 8.0.")
|
359
|
+
end
|
360
|
+
|
361
|
+
def read_encrypted_secrets=(value)
|
362
|
+
Rails.deprecator.warn("'config.read_encrypted_secrets=' is deprecated and will be removed in Rails 8.0.")
|
363
|
+
end
|
364
|
+
|
267
365
|
def encoding=(value)
|
268
366
|
@encoding = value
|
269
367
|
silence_warnings do
|
@@ -279,6 +377,13 @@ module Rails
|
|
279
377
|
@debug_exception_response_format ||= :api
|
280
378
|
end
|
281
379
|
|
380
|
+
def log_level=(level)
|
381
|
+
@log_level = level
|
382
|
+
@broadcast_log_level = level
|
383
|
+
end
|
384
|
+
|
385
|
+
attr_reader :broadcast_log_level # :nodoc:
|
386
|
+
|
282
387
|
def debug_exception_response_format
|
283
388
|
@debug_exception_response_format || :default
|
284
389
|
end
|
@@ -289,7 +394,6 @@ module Rails
|
|
289
394
|
@paths ||= begin
|
290
395
|
paths = super
|
291
396
|
paths.add "config/database", with: "config/database.yml"
|
292
|
-
paths.add "config/secrets", with: "config", glob: "secrets.yml{,.enc}"
|
293
397
|
paths.add "config/environment", with: "config/environment.rb"
|
294
398
|
paths.add "lib/templates"
|
295
399
|
paths.add "log", with: "log/#{Rails.env}.log"
|
@@ -301,23 +405,21 @@ module Rails
|
|
301
405
|
end
|
302
406
|
end
|
303
407
|
|
304
|
-
# Load the database
|
305
|
-
#
|
306
|
-
# configuration values
|
307
|
-
# method.
|
408
|
+
# Load the <tt>config/database.yml</tt> to create the Rake tasks for
|
409
|
+
# multiple databases without loading the environment and filling in the
|
410
|
+
# environment specific configuration values.
|
308
411
|
#
|
309
|
-
#
|
310
|
-
# tags and load the database.yml for the rake tasks.
|
412
|
+
# Do not use this method, use #database_configuration instead.
|
311
413
|
def load_database_yaml # :nodoc:
|
312
414
|
if path = paths["config/database"].existent.first
|
313
|
-
require "rails/application/
|
314
|
-
|
315
|
-
yaml = DummyERB.new(Pathname.new(path).read).result
|
415
|
+
require "rails/application/dummy_config"
|
416
|
+
original_rails_config = Rails.application.config
|
316
417
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
418
|
+
begin
|
419
|
+
Rails.application.config = DummyConfig.new(original_rails_config)
|
420
|
+
ActiveSupport::ConfigurationFile.parse(Pathname.new(path))
|
421
|
+
ensure
|
422
|
+
Rails.application.config = original_rails_config
|
321
423
|
end
|
322
424
|
else
|
323
425
|
{}
|
@@ -335,8 +437,14 @@ module Rails
|
|
335
437
|
if (shared = loaded_yaml.delete("shared"))
|
336
438
|
loaded_yaml.each do |env, config|
|
337
439
|
if config.is_a?(Hash) && config.values.all?(Hash)
|
338
|
-
|
339
|
-
sub_config
|
440
|
+
if shared.is_a?(Hash) && shared.values.all?(Hash)
|
441
|
+
config.map do |name, sub_config|
|
442
|
+
sub_config.reverse_merge!(shared[name])
|
443
|
+
end
|
444
|
+
else
|
445
|
+
config.map do |name, sub_config|
|
446
|
+
sub_config.reverse_merge!(shared)
|
447
|
+
end
|
340
448
|
end
|
341
449
|
else
|
342
450
|
config.reverse_merge!(shared)
|
@@ -357,6 +465,30 @@ module Rails
|
|
357
465
|
raise e, "Cannot load database configuration:\n#{e.message}", e.backtrace
|
358
466
|
end
|
359
467
|
|
468
|
+
def autoload_lib(ignore:)
|
469
|
+
lib = root.join("lib")
|
470
|
+
|
471
|
+
# Set as a string to have the same type as default autoload paths, for
|
472
|
+
# consistency.
|
473
|
+
autoload_paths << lib.to_s
|
474
|
+
eager_load_paths << lib.to_s
|
475
|
+
|
476
|
+
ignored_abspaths = Array.wrap(ignore).map { lib.join(_1) }
|
477
|
+
Rails.autoloaders.main.ignore(ignored_abspaths)
|
478
|
+
end
|
479
|
+
|
480
|
+
def autoload_lib_once(ignore:)
|
481
|
+
lib = root.join("lib")
|
482
|
+
|
483
|
+
# Set as a string to have the same type as default autoload paths, for
|
484
|
+
# consistency.
|
485
|
+
autoload_once_paths << lib.to_s
|
486
|
+
eager_load_paths << lib.to_s
|
487
|
+
|
488
|
+
ignored_abspaths = Array.wrap(ignore).map { lib.join(_1) }
|
489
|
+
Rails.autoloaders.once.ignore(ignored_abspaths)
|
490
|
+
end
|
491
|
+
|
360
492
|
def colorize_logging
|
361
493
|
ActiveSupport::LogSubscriber.colorize_logging
|
362
494
|
end
|
@@ -366,9 +498,32 @@ module Rails
|
|
366
498
|
generators.colorize_logging = val
|
367
499
|
end
|
368
500
|
|
501
|
+
def secret_key_base
|
502
|
+
@secret_key_base || begin
|
503
|
+
self.secret_key_base = if generate_local_secret?
|
504
|
+
generate_local_secret
|
505
|
+
else
|
506
|
+
ENV["SECRET_KEY_BASE"] || Rails.application.credentials.secret_key_base
|
507
|
+
end
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
511
|
+
def secret_key_base=(new_secret_key_base)
|
512
|
+
if new_secret_key_base.nil? && generate_local_secret?
|
513
|
+
@secret_key_base = generate_local_secret
|
514
|
+
elsif new_secret_key_base.is_a?(String) && new_secret_key_base.present?
|
515
|
+
@secret_key_base = new_secret_key_base
|
516
|
+
elsif new_secret_key_base
|
517
|
+
raise ArgumentError, "`secret_key_base` for #{Rails.env} environment must be a type of String`"
|
518
|
+
else
|
519
|
+
raise ArgumentError, "Missing `secret_key_base` for '#{Rails.env}' environment, set this string with `bin/rails credentials:edit`"
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
369
523
|
# Specifies what class to use to store the session. Possible values
|
370
|
-
# are +:cookie_store+, +:mem_cache_store+, a custom
|
371
|
-
# +:disabled+. +:disabled+ tells Rails not to deal with
|
524
|
+
# are +:cache_store+, +:cookie_store+, +:mem_cache_store+, a custom
|
525
|
+
# store, or +:disabled+. +:disabled+ tells \Rails not to deal with
|
526
|
+
# sessions.
|
372
527
|
#
|
373
528
|
# Additional options will be set as +session_options+:
|
374
529
|
#
|
@@ -382,25 +537,14 @@ module Rails
|
|
382
537
|
# config.session_store :my_custom_store
|
383
538
|
def session_store(new_session_store = nil, **options)
|
384
539
|
if new_session_store
|
385
|
-
if new_session_store == :active_record_store
|
386
|
-
begin
|
387
|
-
ActionDispatch::Session::ActiveRecordStore
|
388
|
-
rescue NameError
|
389
|
-
raise "`ActiveRecord::SessionStore` is extracted out of Rails into a gem. " \
|
390
|
-
"Please add `activerecord-session_store` to your Gemfile to use it."
|
391
|
-
end
|
392
|
-
end
|
393
|
-
|
394
540
|
@session_store = new_session_store
|
395
541
|
@session_options = options || {}
|
396
542
|
else
|
397
543
|
case @session_store
|
398
544
|
when :disabled
|
399
545
|
nil
|
400
|
-
when :active_record_store
|
401
|
-
ActionDispatch::Session::ActiveRecordStore
|
402
546
|
when Symbol
|
403
|
-
ActionDispatch::Session.
|
547
|
+
ActionDispatch::Session.resolve_store(@session_store)
|
404
548
|
else
|
405
549
|
@session_store
|
406
550
|
end
|
@@ -445,6 +589,10 @@ module Rails
|
|
445
589
|
f
|
446
590
|
end
|
447
591
|
|
592
|
+
def inspect # :nodoc:
|
593
|
+
"#<#{self.class.name}:#{'%#016x' % (object_id << 1)}>"
|
594
|
+
end
|
595
|
+
|
448
596
|
class Custom # :nodoc:
|
449
597
|
def initialize
|
450
598
|
@configurations = Hash.new
|
@@ -453,37 +601,45 @@ module Rails
|
|
453
601
|
def method_missing(method, *args)
|
454
602
|
if method.end_with?("=")
|
455
603
|
@configurations[:"#{method[0..-2]}"] = args.first
|
456
|
-
|
604
|
+
elsif args.empty?
|
457
605
|
@configurations.fetch(method) {
|
458
606
|
@configurations[method] = ActiveSupport::OrderedOptions.new
|
459
607
|
}
|
608
|
+
else
|
609
|
+
raise ArgumentError, "wrong number of arguments (given #{args.length}, expected 0) when reading configuration `#{method}`"
|
460
610
|
end
|
461
611
|
end
|
462
612
|
|
463
|
-
def respond_to_missing?(symbol,
|
613
|
+
def respond_to_missing?(symbol, _)
|
464
614
|
true
|
465
615
|
end
|
466
616
|
end
|
467
617
|
|
468
618
|
private
|
469
|
-
def
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
619
|
+
def credentials_defaults
|
620
|
+
content_path = root.join("config/credentials/#{Rails.env}.yml.enc")
|
621
|
+
content_path = root.join("config/credentials.yml.enc") if !content_path.exist?
|
622
|
+
|
623
|
+
key_path = root.join("config/credentials/#{Rails.env}.key")
|
624
|
+
key_path = root.join("config/master.key") if !key_path.exist?
|
625
|
+
|
626
|
+
{ content_path: content_path, key_path: key_path }
|
475
627
|
end
|
476
628
|
|
477
|
-
def
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
629
|
+
def generate_local_secret
|
630
|
+
key_file = root.join("tmp/local_secret.txt")
|
631
|
+
|
632
|
+
unless File.exist?(key_file)
|
633
|
+
random_key = SecureRandom.hex(64)
|
634
|
+
FileUtils.mkdir_p(key_file.dirname)
|
635
|
+
File.binwrite(key_file, random_key)
|
482
636
|
end
|
637
|
+
|
638
|
+
File.binread(key_file)
|
483
639
|
end
|
484
640
|
|
485
|
-
def
|
486
|
-
|
641
|
+
def generate_local_secret?
|
642
|
+
Rails.env.local? || ENV["SECRET_KEY_BASE_DUMMY"]
|
487
643
|
end
|
488
644
|
end
|
489
645
|
end
|
@@ -13,7 +13,13 @@ module Rails
|
|
13
13
|
|
14
14
|
def build_stack
|
15
15
|
ActionDispatch::MiddlewareStack.new do |middleware|
|
16
|
-
|
16
|
+
unless Array(config.hosts).empty?
|
17
|
+
middleware.use ::ActionDispatch::HostAuthorization, config.hosts, **config.host_authorization
|
18
|
+
end
|
19
|
+
|
20
|
+
if config.assume_ssl
|
21
|
+
middleware.use ::ActionDispatch::AssumeSSL
|
22
|
+
end
|
17
23
|
|
18
24
|
if config.force_ssl
|
19
25
|
middleware.use ::ActionDispatch::SSL, **config.ssl_options,
|
@@ -56,7 +62,7 @@ module Rails
|
|
56
62
|
middleware.use ::ActionDispatch::ActionableExceptions
|
57
63
|
end
|
58
64
|
|
59
|
-
|
65
|
+
if config.reloading_enabled?
|
60
66
|
middleware.use ::ActionDispatch::Reloader, app.reloader
|
61
67
|
end
|
62
68
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DummyConfig # :nodoc:
|
4
|
+
def initialize(config)
|
5
|
+
@config = config
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_s
|
9
|
+
"DummyConfig"
|
10
|
+
end
|
11
|
+
|
12
|
+
def method_missing(selector, ...)
|
13
|
+
if @config.respond_to?(selector)
|
14
|
+
@config.send(selector, ...)
|
15
|
+
else
|
16
|
+
self
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|