railties 7.0.8.7 → 7.1.5.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 +723 -215
- data/MIT-LICENSE +1 -1
- data/RDOC_MAIN.md +99 -0
- data/README.rdoc +4 -4
- data/lib/minitest/rails_plugin.rb +63 -0
- data/lib/rails/api/task.rb +35 -4
- data/lib/rails/app_updater.rb +14 -2
- data/lib/rails/application/bootstrap.rb +23 -4
- data/lib/rails/application/configuration.rb +190 -69
- 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 +43 -33
- data/lib/rails/application.rb +141 -33
- data/lib/rails/backtrace_cleaner.rb +5 -3
- data/lib/rails/cli.rb +5 -2
- 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/application/application_command.rb +2 -0
- data/lib/rails/commands/console/console_command.rb +14 -14
- 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 +25 -115
- data/lib/rails/commands/destroy/destroy_command.rb +3 -2
- data/lib/rails/commands/dev/dev_command.rb +1 -6
- 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 +32 -20
- data/lib/rails/commands/secret/secret_command.rb +13 -0
- data/lib/rails/commands/secrets/USAGE +44 -49
- data/lib/rails/commands/secrets/secrets_command.rb +20 -38
- data/lib/rails/commands/server/server_command.rb +33 -32
- data/lib/rails/commands/test/USAGE +14 -0
- data/lib/rails/commands/test/test_command.rb +56 -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 +5 -5
- data/lib/rails/console/app.rb +1 -4
- data/lib/rails/deprecator.rb +7 -0
- data/lib/rails/engine/configuration.rb +50 -6
- data/lib/rails/engine.rb +49 -21
- 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 +355 -82
- data/lib/rails/generators/app_name.rb +3 -14
- data/lib/rails/generators/base.rb +17 -9
- data/lib/rails/generators/database.rb +40 -2
- data/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt +1 -1
- data/lib/rails/generators/generated_attribute.rb +12 -0
- 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 +85 -64
- data/lib/rails/generators/rails/app/templates/Dockerfile.tt +103 -0
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +9 -11
- data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +10 -1
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +6 -17
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +4 -4
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +4 -6
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +59 -0
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +12 -2
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +32 -28
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +13 -9
- data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +2 -0
- 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 +3 -3
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_1.rb.tt +280 -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 +21 -20
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +5 -1
- data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +6 -4
- data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +10 -0
- data/lib/rails/generators/rails/app/templates/dockerignore.tt +43 -0
- data/lib/rails/generators/rails/app/templates/gitignore.tt +4 -8
- data/lib/rails/generators/rails/app/templates/node-version.tt +1 -0
- 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 +5 -0
- 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 +30 -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/model/model_generator.rb +4 -0
- data/lib/rails/generators/rails/plugin/USAGE +17 -6
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +5 -15
- data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +2 -2
- data/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +1 -17
- data/lib/rails/generators/rails/plugin/templates/gitignore.tt +0 -2
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +4 -4
- 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/scaffold/scaffold_generator.rb +1 -1
- data/lib/rails/generators/testing/{behaviour.rb → behavior.rb} +4 -1
- data/lib/rails/generators.rb +6 -14
- data/lib/rails/health_controller.rb +55 -0
- data/lib/rails/info.rb +1 -1
- data/lib/rails/info_controller.rb +33 -11
- data/lib/rails/mailers_controller.rb +15 -5
- data/lib/rails/paths.rb +13 -10
- data/lib/rails/rack/logger.rb +15 -12
- data/lib/rails/rackup/server.rb +15 -0
- data/lib/rails/railtie/configuration.rb +14 -1
- data/lib/rails/railtie.rb +31 -31
- data/lib/rails/ruby_version_check.rb +2 -0
- data/lib/rails/source_annotation_extractor.rb +67 -18
- data/lib/rails/tasks/engine.rake +8 -8
- data/lib/rails/tasks/framework.rake +4 -10
- 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 +5 -5
- data/lib/rails/tasks/zeitwerk.rake +15 -35
- data/lib/rails/tasks.rb +0 -2
- data/lib/rails/templates/rails/mailers/email.html.erb +32 -0
- 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 +1 -0
- data/lib/rails/test_help.rb +9 -14
- data/lib/rails/test_unit/line_filtering.rb +1 -1
- data/lib/rails/test_unit/reporter.rb +6 -2
- data/lib/rails/test_unit/runner.rb +36 -18
- data/lib/rails/test_unit/test_parser.rb +88 -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 +15 -15
- metadata +64 -27
- data/RDOC_MAIN.rdoc +0 -97
- data/lib/rails/application/dummy_erb_compiler.rb +0 -18
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_0.rb.tt +0 -143
- data/lib/rails/generators/rails/model/USAGE +0 -113
- 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
18
|
:log_tags, :railties_order, :relative_url_root, :secret_key_base,
|
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
|
-
:read_encrypted_secrets, :
|
21
|
+
:beginning_of_week, :filter_redirect, :x,
|
22
|
+
:read_encrypted_secrets, :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
|
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]
|
@@ -71,27 +75,44 @@ module Rails
|
|
71
75
|
@content_security_policy_nonce_directives = nil
|
72
76
|
@require_master_key = false
|
73
77
|
@loaded_config_version = nil
|
74
|
-
@credentials = ActiveSupport::
|
75
|
-
@credentials.content_path = default_credentials_content_path
|
76
|
-
@credentials.key_path = default_credentials_key_path
|
78
|
+
@credentials = ActiveSupport::InheritableOptions.new(credentials_defaults)
|
77
79
|
@disable_sandbox = false
|
80
|
+
@sandbox_by_default = false
|
78
81
|
@add_autoload_paths_to_load_path = true
|
79
82
|
@permissions_policy = nil
|
80
83
|
@rake_eager_load = false
|
81
84
|
@server_timing = false
|
85
|
+
@dom_testing_default_html_version = :html4
|
82
86
|
end
|
83
87
|
|
84
88
|
# Loads default configuration values for a target version. This includes
|
85
89
|
# defaults for versions prior to the target version. See the
|
86
|
-
# {configuration guide}[https://guides.rubyonrails.org/configuring.html]
|
90
|
+
# {configuration guide}[https://guides.rubyonrails.org/configuring.html#versioned-default-values]
|
87
91
|
# for the default values associated with a particular version.
|
88
92
|
def load_defaults(target_version)
|
93
|
+
# To introduce a change in behavior, follow these steps:
|
94
|
+
# 1. Add an accessor on the target object (e.g. the ActiveJob class for
|
95
|
+
# global Active Job config).
|
96
|
+
# 2. Set a default value there preserving existing behavior for existing
|
97
|
+
# applications.
|
98
|
+
# 3. Implement the behavior change based on the config value.
|
99
|
+
# 4. In the section below corresponding to the next release of Rails,
|
100
|
+
# configure the default value.
|
101
|
+
# 5. Add a commented out section in the `new_framework_defaults` to
|
102
|
+
# configure the default value again.
|
103
|
+
# 6. Update the guide in `configuring.md`.
|
104
|
+
|
105
|
+
# To remove configurable deprecated behavior, follow these steps:
|
106
|
+
# 1. Update or remove the entry in the guides.
|
107
|
+
# 2. Remove the references below.
|
108
|
+
# 3. Remove the legacy code paths and config check.
|
109
|
+
# 4. Remove the config accessor.
|
110
|
+
|
89
111
|
case target_version.to_s
|
90
112
|
when "5.0"
|
91
113
|
if respond_to?(:action_controller)
|
92
114
|
action_controller.per_form_csrf_tokens = true
|
93
115
|
action_controller.forgery_protection_origin_check = true
|
94
|
-
action_controller.urlsafe_csrf_tokens = false
|
95
116
|
end
|
96
117
|
|
97
118
|
ActiveSupport.to_time_preserves_timezone = true
|
@@ -152,8 +173,6 @@ module Rails
|
|
152
173
|
if respond_to?(:active_storage)
|
153
174
|
active_storage.queues.analysis = :active_storage_analysis
|
154
175
|
active_storage.queues.purge = :active_storage_purge
|
155
|
-
|
156
|
-
active_storage.replace_on_assign_to_many = true
|
157
176
|
end
|
158
177
|
|
159
178
|
if respond_to?(:active_record)
|
@@ -164,7 +183,6 @@ module Rails
|
|
164
183
|
|
165
184
|
if respond_to?(:active_record)
|
166
185
|
active_record.has_many_inversing = true
|
167
|
-
active_record.legacy_connection_handling = false
|
168
186
|
end
|
169
187
|
|
170
188
|
if respond_to?(:active_job)
|
@@ -176,10 +194,6 @@ module Rails
|
|
176
194
|
action_dispatch.ssl_default_redirect_status = 308
|
177
195
|
end
|
178
196
|
|
179
|
-
if respond_to?(:action_controller)
|
180
|
-
action_controller.delete(:urlsafe_csrf_tokens)
|
181
|
-
end
|
182
|
-
|
183
197
|
if respond_to?(:action_view)
|
184
198
|
action_view.form_with_generates_remote_forms = false
|
185
199
|
action_view.preload_links_header = true
|
@@ -214,7 +228,6 @@ module Rails
|
|
214
228
|
"X-Permitted-Cross-Domain-Policies" => "none",
|
215
229
|
"Referrer-Policy" => "strict-origin-when-cross-origin"
|
216
230
|
}
|
217
|
-
action_dispatch.return_only_request_media_type_on_content_type = false
|
218
231
|
action_dispatch.cookies_serializer = :json
|
219
232
|
end
|
220
233
|
|
@@ -226,11 +239,8 @@ module Rails
|
|
226
239
|
if respond_to?(:active_support)
|
227
240
|
active_support.hash_digest_class = OpenSSL::Digest::SHA256
|
228
241
|
active_support.key_generator_hash_digest_class = OpenSSL::Digest::SHA256
|
229
|
-
active_support.remove_deprecated_time_with_zone_name = true
|
230
242
|
active_support.cache_format_version = 7.0
|
231
|
-
active_support.use_rfc4122_namespaced_uuids = true
|
232
243
|
active_support.executor_around_test_case = true
|
233
|
-
active_support.disable_to_s_conversion = true
|
234
244
|
end
|
235
245
|
|
236
246
|
if respond_to?(:action_mailer)
|
@@ -254,9 +264,71 @@ module Rails
|
|
254
264
|
|
255
265
|
if respond_to?(:action_controller)
|
256
266
|
action_controller.raise_on_open_redirects = true
|
257
|
-
|
258
267
|
action_controller.wrap_parameters_by_default = true
|
259
268
|
end
|
269
|
+
when "7.1"
|
270
|
+
load_defaults "7.0"
|
271
|
+
|
272
|
+
self.add_autoload_paths_to_load_path = false
|
273
|
+
self.precompile_filter_parameters = true
|
274
|
+
self.dom_testing_default_html_version = defined?(Nokogiri::HTML5) ? :html5 : :html4
|
275
|
+
|
276
|
+
if Rails.env.local?
|
277
|
+
self.log_file_size = 100 * 1024 * 1024
|
278
|
+
end
|
279
|
+
|
280
|
+
if respond_to?(:active_record)
|
281
|
+
active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false
|
282
|
+
active_record.commit_transaction_on_non_local_return = true
|
283
|
+
active_record.allow_deprecated_singular_associations_name = false
|
284
|
+
active_record.sqlite3_adapter_strict_strings_by_default = true
|
285
|
+
active_record.query_log_tags_format = :sqlcommenter
|
286
|
+
active_record.raise_on_assign_to_attr_readonly = true
|
287
|
+
active_record.belongs_to_required_validates_foreign_key = false
|
288
|
+
active_record.before_committed_on_all_records = true
|
289
|
+
active_record.default_column_serializer = nil
|
290
|
+
active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA256
|
291
|
+
active_record.encryption.support_sha1_for_non_deterministic_encryption = false
|
292
|
+
active_record.marshalling_format_version = 7.1
|
293
|
+
active_record.run_after_transaction_callbacks_in_order_defined = true
|
294
|
+
active_record.generate_secure_token_on = :initialize
|
295
|
+
end
|
296
|
+
|
297
|
+
if respond_to?(:action_dispatch)
|
298
|
+
action_dispatch.default_headers = {
|
299
|
+
"X-Frame-Options" => "SAMEORIGIN",
|
300
|
+
"X-XSS-Protection" => "0",
|
301
|
+
"X-Content-Type-Options" => "nosniff",
|
302
|
+
"X-Permitted-Cross-Domain-Policies" => "none",
|
303
|
+
"Referrer-Policy" => "strict-origin-when-cross-origin"
|
304
|
+
}
|
305
|
+
action_dispatch.debug_exception_log_level = :error
|
306
|
+
end
|
307
|
+
|
308
|
+
if respond_to?(:active_job)
|
309
|
+
active_job.use_big_decimal_serializer = true
|
310
|
+
end
|
311
|
+
|
312
|
+
if respond_to?(:active_support)
|
313
|
+
active_support.cache_format_version = 7.1
|
314
|
+
active_support.message_serializer = :json_allow_marshal
|
315
|
+
active_support.use_message_serializer_for_metadata = true
|
316
|
+
active_support.raise_on_invalid_cache_expiration_time = true
|
317
|
+
end
|
318
|
+
|
319
|
+
if respond_to?(:action_controller)
|
320
|
+
action_controller.allow_deprecated_parameters_hash_equality = false
|
321
|
+
end
|
322
|
+
|
323
|
+
if respond_to?(:action_view)
|
324
|
+
require "action_view/helpers"
|
325
|
+
action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
|
326
|
+
end
|
327
|
+
|
328
|
+
if respond_to?(:action_text)
|
329
|
+
require "action_view/helpers"
|
330
|
+
action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
|
331
|
+
end
|
260
332
|
else
|
261
333
|
raise "Unknown version #{target_version.to_s.inspect}"
|
262
334
|
end
|
@@ -264,6 +336,34 @@ module Rails
|
|
264
336
|
@loaded_config_version = target_version
|
265
337
|
end
|
266
338
|
|
339
|
+
def reloading_enabled?
|
340
|
+
enable_reloading
|
341
|
+
end
|
342
|
+
|
343
|
+
def enable_reloading
|
344
|
+
!cache_classes
|
345
|
+
end
|
346
|
+
|
347
|
+
def enable_reloading=(value)
|
348
|
+
self.cache_classes = !value
|
349
|
+
end
|
350
|
+
|
351
|
+
ENABLE_DEPENDENCY_LOADING_WARNING = <<~MSG
|
352
|
+
This flag addressed a limitation of the `classic` autoloader and has no effect nowadays.
|
353
|
+
To fix this deprecation, please just delete the reference.
|
354
|
+
MSG
|
355
|
+
private_constant :ENABLE_DEPENDENCY_LOADING_WARNING
|
356
|
+
|
357
|
+
def enable_dependency_loading
|
358
|
+
Rails.deprecator.warn(ENABLE_DEPENDENCY_LOADING_WARNING)
|
359
|
+
@enable_dependency_loading
|
360
|
+
end
|
361
|
+
|
362
|
+
def enable_dependency_loading=(value)
|
363
|
+
Rails.deprecator.warn(ENABLE_DEPENDENCY_LOADING_WARNING)
|
364
|
+
@enable_dependency_loading = value
|
365
|
+
end
|
366
|
+
|
267
367
|
def encoding=(value)
|
268
368
|
@encoding = value
|
269
369
|
silence_warnings do
|
@@ -279,6 +379,15 @@ module Rails
|
|
279
379
|
@debug_exception_response_format ||= :api
|
280
380
|
end
|
281
381
|
|
382
|
+
def log_level=(level)
|
383
|
+
@log_level = level
|
384
|
+
@broadcast_log_level = level
|
385
|
+
end
|
386
|
+
|
387
|
+
def broadcast_log_level # :nodoc:
|
388
|
+
defined?(@broadcast_log_level) ? @broadcast_log_level : nil
|
389
|
+
end
|
390
|
+
|
282
391
|
def debug_exception_response_format
|
283
392
|
@debug_exception_response_format || :default
|
284
393
|
end
|
@@ -301,23 +410,21 @@ module Rails
|
|
301
410
|
end
|
302
411
|
end
|
303
412
|
|
304
|
-
# Load the database
|
305
|
-
#
|
306
|
-
# configuration values
|
307
|
-
# method.
|
413
|
+
# Load the <tt>config/database.yml</tt> to create the Rake tasks for
|
414
|
+
# multiple databases without loading the environment and filling in the
|
415
|
+
# environment specific configuration values.
|
308
416
|
#
|
309
|
-
#
|
310
|
-
# tags and load the database.yml for the rake tasks.
|
417
|
+
# Do not use this method, use #database_configuration instead.
|
311
418
|
def load_database_yaml # :nodoc:
|
312
419
|
if path = paths["config/database"].existent.first
|
313
|
-
require "rails/application/
|
314
|
-
|
315
|
-
yaml = DummyERB.new(Pathname.new(path).read).result
|
420
|
+
require "rails/application/dummy_config"
|
421
|
+
original_rails_config = Rails.application.config
|
316
422
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
423
|
+
begin
|
424
|
+
Rails.application.config = DummyConfig.new(original_rails_config)
|
425
|
+
ActiveSupport::ConfigurationFile.parse(Pathname.new(path))
|
426
|
+
ensure
|
427
|
+
Rails.application.config = original_rails_config
|
321
428
|
end
|
322
429
|
else
|
323
430
|
{}
|
@@ -335,8 +442,14 @@ module Rails
|
|
335
442
|
if (shared = loaded_yaml.delete("shared"))
|
336
443
|
loaded_yaml.each do |env, config|
|
337
444
|
if config.is_a?(Hash) && config.values.all?(Hash)
|
338
|
-
|
339
|
-
sub_config
|
445
|
+
if shared.is_a?(Hash) && shared.values.all?(Hash)
|
446
|
+
config.map do |name, sub_config|
|
447
|
+
sub_config.reverse_merge!(shared[name])
|
448
|
+
end
|
449
|
+
else
|
450
|
+
config.map do |name, sub_config|
|
451
|
+
sub_config.reverse_merge!(shared)
|
452
|
+
end
|
340
453
|
end
|
341
454
|
else
|
342
455
|
config.reverse_merge!(shared)
|
@@ -357,6 +470,30 @@ module Rails
|
|
357
470
|
raise e, "Cannot load database configuration:\n#{e.message}", e.backtrace
|
358
471
|
end
|
359
472
|
|
473
|
+
def autoload_lib(ignore:)
|
474
|
+
lib = root.join("lib")
|
475
|
+
|
476
|
+
# Set as a string to have the same type as default autoload paths, for
|
477
|
+
# consistency.
|
478
|
+
autoload_paths << lib.to_s
|
479
|
+
eager_load_paths << lib.to_s
|
480
|
+
|
481
|
+
ignored_abspaths = Array.wrap(ignore).map { lib.join(_1) }
|
482
|
+
Rails.autoloaders.main.ignore(ignored_abspaths)
|
483
|
+
end
|
484
|
+
|
485
|
+
def autoload_lib_once(ignore:)
|
486
|
+
lib = root.join("lib")
|
487
|
+
|
488
|
+
# Set as a string to have the same type as default autoload paths, for
|
489
|
+
# consistency.
|
490
|
+
autoload_once_paths << lib.to_s
|
491
|
+
eager_load_paths << lib.to_s
|
492
|
+
|
493
|
+
ignored_abspaths = Array.wrap(ignore).map { lib.join(_1) }
|
494
|
+
Rails.autoloaders.once.ignore(ignored_abspaths)
|
495
|
+
end
|
496
|
+
|
360
497
|
def colorize_logging
|
361
498
|
ActiveSupport::LogSubscriber.colorize_logging
|
362
499
|
end
|
@@ -367,8 +504,9 @@ module Rails
|
|
367
504
|
end
|
368
505
|
|
369
506
|
# 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
|
507
|
+
# are +:cache_store+, +:cookie_store+, +:mem_cache_store+, a custom
|
508
|
+
# store, or +:disabled+. +:disabled+ tells \Rails not to deal with
|
509
|
+
# sessions.
|
372
510
|
#
|
373
511
|
# Additional options will be set as +session_options+:
|
374
512
|
#
|
@@ -382,25 +520,14 @@ module Rails
|
|
382
520
|
# config.session_store :my_custom_store
|
383
521
|
def session_store(new_session_store = nil, **options)
|
384
522
|
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
523
|
@session_store = new_session_store
|
395
524
|
@session_options = options || {}
|
396
525
|
else
|
397
526
|
case @session_store
|
398
527
|
when :disabled
|
399
528
|
nil
|
400
|
-
when :active_record_store
|
401
|
-
ActionDispatch::Session::ActiveRecordStore
|
402
529
|
when Symbol
|
403
|
-
ActionDispatch::Session.
|
530
|
+
ActionDispatch::Session.resolve_store(@session_store)
|
404
531
|
else
|
405
532
|
@session_store
|
406
533
|
end
|
@@ -445,6 +572,10 @@ module Rails
|
|
445
572
|
f
|
446
573
|
end
|
447
574
|
|
575
|
+
def inspect # :nodoc:
|
576
|
+
"#<#{self.class.name}:#{'%#016x' % (object_id << 1)}>"
|
577
|
+
end
|
578
|
+
|
448
579
|
class Custom # :nodoc:
|
449
580
|
def initialize
|
450
581
|
@configurations = Hash.new
|
@@ -466,24 +597,14 @@ module Rails
|
|
466
597
|
end
|
467
598
|
|
468
599
|
private
|
469
|
-
def
|
470
|
-
|
471
|
-
|
472
|
-
else
|
473
|
-
root.join("config", "credentials.yml.enc")
|
474
|
-
end
|
475
|
-
end
|
600
|
+
def credentials_defaults
|
601
|
+
content_path = root.join("config/credentials/#{Rails.env}.yml.enc")
|
602
|
+
content_path = root.join("config/credentials.yml.enc") if !content_path.exist?
|
476
603
|
|
477
|
-
|
478
|
-
if
|
479
|
-
root.join("config", "credentials", "#{Rails.env}.key")
|
480
|
-
else
|
481
|
-
root.join("config", "master.key")
|
482
|
-
end
|
483
|
-
end
|
604
|
+
key_path = root.join("config/credentials/#{Rails.env}.key")
|
605
|
+
key_path = root.join("config/master.key") if !key_path.exist?
|
484
606
|
|
485
|
-
|
486
|
-
File.exist?(root.join("config", "credentials", "#{Rails.env}.yml.enc"))
|
607
|
+
{ content_path: content_path, key_path: key_path }
|
487
608
|
end
|
488
609
|
end
|
489
610
|
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, *args, &blk)
|
13
|
+
if @config.respond_to?(selector)
|
14
|
+
@config.send(selector, *args, &blk)
|
15
|
+
else
|
16
|
+
self
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "set"
|
3
4
|
require "active_support/core_ext/string/inflections"
|
4
5
|
require "active_support/core_ext/array/conversions"
|
5
6
|
require "active_support/descendants_tracker"
|
@@ -11,22 +12,27 @@ module Rails
|
|
11
12
|
include Initializable
|
12
13
|
|
13
14
|
initializer :add_generator_templates do
|
14
|
-
|
15
|
+
ensure_generator_templates_added
|
15
16
|
end
|
16
17
|
|
17
18
|
initializer :setup_main_autoloader do
|
18
19
|
autoloader = Rails.autoloaders.main
|
19
20
|
|
21
|
+
# Normally empty, but if the user already defined some, we won't
|
22
|
+
# override them. Important if there are custom namespaces associated.
|
23
|
+
already_configured_dirs = Set.new(autoloader.dirs)
|
24
|
+
|
20
25
|
ActiveSupport::Dependencies.autoload_paths.freeze
|
21
26
|
ActiveSupport::Dependencies.autoload_paths.uniq.each do |path|
|
22
27
|
# Zeitwerk only accepts existing directories in `push_dir`.
|
23
28
|
next unless File.directory?(path)
|
29
|
+
next if already_configured_dirs.member?(path.to_s)
|
24
30
|
|
25
31
|
autoloader.push_dir(path)
|
26
32
|
autoloader.do_not_eager_load(path) unless ActiveSupport::Dependencies.eager_load?(path)
|
27
33
|
end
|
28
34
|
|
29
|
-
|
35
|
+
if config.reloading_enabled?
|
30
36
|
autoloader.enable_reloading
|
31
37
|
ActiveSupport::Dependencies.autoloader = autoloader
|
32
38
|
|
@@ -74,7 +80,7 @@ module Rails
|
|
74
80
|
Zeitwerk::Loader.eager_load_all
|
75
81
|
config.eager_load_namespaces.each(&:eager_load!)
|
76
82
|
|
77
|
-
|
83
|
+
if config.reloading_enabled?
|
78
84
|
app.reloader.after_class_unload do
|
79
85
|
Rails.autoloaders.main.eager_load
|
80
86
|
end
|
@@ -125,10 +131,7 @@ module Rails
|
|
125
131
|
else
|
126
132
|
# Default concurrency setting: enabled, but safe
|
127
133
|
|
128
|
-
|
129
|
-
# Without cache_classes + eager_load, the load interlock
|
130
|
-
# is required for proper operation
|
131
|
-
|
134
|
+
if config.reloading_enabled?
|
132
135
|
app.executor.register_hook(InterlockHook, outer: true)
|
133
136
|
end
|
134
137
|
end
|
@@ -157,6 +160,7 @@ module Rails
|
|
157
160
|
reloader.eager_load = app.config.eager_load
|
158
161
|
reloader.execute
|
159
162
|
reloaders << reloader
|
163
|
+
|
160
164
|
app.reloader.to_run do
|
161
165
|
# We configure #execute rather than #execute_if_updated because if
|
162
166
|
# autoloaded constants are cleared we need to reload routes also in
|
@@ -169,7 +173,10 @@ module Rails
|
|
169
173
|
# some sort of reloaders dependency support, to be added.
|
170
174
|
require_unload_lock!
|
171
175
|
reloader.execute
|
176
|
+
ActiveSupport.run_load_hooks(:after_routes_loaded, self)
|
172
177
|
end
|
178
|
+
|
179
|
+
ActiveSupport.run_load_hooks(:after_routes_loaded, self)
|
173
180
|
end
|
174
181
|
|
175
182
|
# Set clearing dependencies after the finisher hook to ensure paths
|
@@ -181,39 +188,42 @@ module Rails
|
|
181
188
|
ActiveSupport::Dependencies.clear
|
182
189
|
end
|
183
190
|
|
184
|
-
if config.
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
191
|
+
if config.reloading_enabled?
|
192
|
+
if config.reload_classes_only_on_change
|
193
|
+
app.reloader.check = lambda do
|
194
|
+
app.reloaders.map(&:updated?).any?
|
195
|
+
end
|
196
|
+
else
|
197
|
+
app.reloader.check = lambda { true }
|
189
198
|
end
|
190
199
|
else
|
191
|
-
app.reloader.check = lambda {
|
200
|
+
app.reloader.check = lambda { false }
|
192
201
|
end
|
193
202
|
|
194
|
-
if config.
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
203
|
+
if config.reloading_enabled?
|
204
|
+
if config.reload_classes_only_on_change
|
205
|
+
reloader = config.file_watcher.new(*watchable_args, &callback)
|
206
|
+
reloaders << reloader
|
207
|
+
|
208
|
+
# Prepend this callback to have autoloaded constants cleared before
|
209
|
+
# any other possible reloading, in case they need to autoload fresh
|
210
|
+
# constants.
|
211
|
+
app.reloader.to_run(prepend: true) do
|
212
|
+
# In addition to changes detected by the file watcher, if routes
|
213
|
+
# or i18n have been updated we also need to clear constants,
|
214
|
+
# that's why we run #execute rather than #execute_if_updated, this
|
215
|
+
# callback has to clear autoloaded constants after any update.
|
216
|
+
class_unload! do
|
217
|
+
reloader.execute
|
218
|
+
end
|
219
|
+
end
|
220
|
+
else
|
221
|
+
app.reloader.to_complete do
|
222
|
+
class_unload!(&callback)
|
211
223
|
end
|
212
224
|
end
|
213
225
|
else
|
214
|
-
|
215
|
-
class_unload!(&callback)
|
216
|
-
end
|
226
|
+
ActiveSupport::DescendantsTracker.disable_clear!
|
217
227
|
end
|
218
228
|
end
|
219
229
|
end
|