railties 7.0.8.7 → 7.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +570 -229
- 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 +1 -1
- data/lib/rails/application/bootstrap.rb +12 -3
- data/lib/rails/application/configuration.rb +179 -67
- 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 +40 -33
- data/lib/rails/application.rb +112 -24
- data/lib/rails/backtrace_cleaner.rb +1 -1
- 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 +19 -38
- data/lib/rails/commands/server/server_command.rb +32 -31
- 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 +5 -0
- data/lib/rails/engine.rb +32 -11
- data/lib/rails/gem_version.rb +4 -4
- data/lib/rails/generators/actions.rb +6 -15
- data/lib/rails/generators/active_model.rb +2 -2
- data/lib/rails/generators/app_base.rb +354 -83
- data/lib/rails/generators/app_name.rb +3 -14
- data/lib/rails/generators/base.rb +12 -4
- data/lib/rails/generators/database.rb +19 -1
- data/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt +1 -1
- data/lib/rails/generators/generated_attribute.rb +2 -0
- data/lib/rails/generators/migration.rb +1 -2
- data/lib/rails/generators/model_helpers.rb +2 -1
- data/lib/rails/generators/rails/app/USAGE +15 -6
- data/lib/rails/generators/rails/app/app_generator.rb +84 -60
- data/lib/rails/generators/rails/app/templates/Dockerfile.tt +107 -0
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +8 -10
- 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 +4 -17
- 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 +0 -2
- 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 +10 -2
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +28 -24
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +11 -7
- 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/new_framework_defaults_7_1.rb.tt +223 -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 +10 -19
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +4 -0
- 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 +1 -9
- 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/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 +5 -13
- data/lib/rails/health_controller.rb +55 -0
- data/lib/rails/info.rb +1 -1
- data/lib/rails/info_controller.rb +31 -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 +18 -18
- 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 +1 -1
- data/lib/rails/tasks.rb +0 -2
- data/lib/rails/templates/rails/mailers/email.html.erb +25 -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 +7 -7
- 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/version.rb +1 -1
- data/lib/rails.rb +15 -15
- metadata +69 -34
- 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,18 +11,19 @@ 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
|
+
:beginning_of_week, :filter_redirect, :x,
|
21
22
|
:read_encrypted_secrets, :log_level, :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
28
|
attr_reader :encoding, :api_only, :loaded_config_version
|
27
29
|
|
@@ -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 defined?(Rails::HTML::Sanitizer) # nested ifs to avoid linter errors
|
324
|
+
if respond_to?(:action_view)
|
325
|
+
action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
|
326
|
+
end
|
327
|
+
|
328
|
+
if respond_to?(:action_text)
|
329
|
+
action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
|
330
|
+
end
|
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
|
@@ -301,23 +401,21 @@ module Rails
|
|
301
401
|
end
|
302
402
|
end
|
303
403
|
|
304
|
-
# Load the database
|
305
|
-
#
|
306
|
-
# configuration values
|
307
|
-
# method.
|
404
|
+
# Load the <tt>config/database.yml</tt> to create the Rake tasks for
|
405
|
+
# multiple databases without loading the environment and filling in the
|
406
|
+
# environment specific configuration values.
|
308
407
|
#
|
309
|
-
#
|
310
|
-
# tags and load the database.yml for the rake tasks.
|
408
|
+
# Do not use this method, use #database_configuration instead.
|
311
409
|
def load_database_yaml # :nodoc:
|
312
410
|
if path = paths["config/database"].existent.first
|
313
|
-
require "rails/application/
|
411
|
+
require "rails/application/dummy_config"
|
412
|
+
original_rails_config = Rails.application.config
|
314
413
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
YAML.load(yaml) || {}
|
414
|
+
begin
|
415
|
+
Rails.application.config = DummyConfig.new(original_rails_config)
|
416
|
+
ActiveSupport::ConfigurationFile.parse(Pathname.new(path))
|
417
|
+
ensure
|
418
|
+
Rails.application.config = original_rails_config
|
321
419
|
end
|
322
420
|
else
|
323
421
|
{}
|
@@ -335,8 +433,14 @@ module Rails
|
|
335
433
|
if (shared = loaded_yaml.delete("shared"))
|
336
434
|
loaded_yaml.each do |env, config|
|
337
435
|
if config.is_a?(Hash) && config.values.all?(Hash)
|
338
|
-
|
339
|
-
sub_config
|
436
|
+
if shared.is_a?(Hash) && shared.values.all?(Hash)
|
437
|
+
config.map do |name, sub_config|
|
438
|
+
sub_config.reverse_merge!(shared[name])
|
439
|
+
end
|
440
|
+
else
|
441
|
+
config.map do |name, sub_config|
|
442
|
+
sub_config.reverse_merge!(shared)
|
443
|
+
end
|
340
444
|
end
|
341
445
|
else
|
342
446
|
config.reverse_merge!(shared)
|
@@ -357,6 +461,30 @@ module Rails
|
|
357
461
|
raise e, "Cannot load database configuration:\n#{e.message}", e.backtrace
|
358
462
|
end
|
359
463
|
|
464
|
+
def autoload_lib(ignore:)
|
465
|
+
lib = root.join("lib")
|
466
|
+
|
467
|
+
# Set as a string to have the same type as default autoload paths, for
|
468
|
+
# consistency.
|
469
|
+
autoload_paths << lib.to_s
|
470
|
+
eager_load_paths << lib.to_s
|
471
|
+
|
472
|
+
ignored_abspaths = Array.wrap(ignore).map { lib.join(_1) }
|
473
|
+
Rails.autoloaders.main.ignore(ignored_abspaths)
|
474
|
+
end
|
475
|
+
|
476
|
+
def autoload_lib_once(ignore:)
|
477
|
+
lib = root.join("lib")
|
478
|
+
|
479
|
+
# Set as a string to have the same type as default autoload paths, for
|
480
|
+
# consistency.
|
481
|
+
autoload_once_paths << lib.to_s
|
482
|
+
eager_load_paths << lib.to_s
|
483
|
+
|
484
|
+
ignored_abspaths = Array.wrap(ignore).map { lib.join(_1) }
|
485
|
+
Rails.autoloaders.once.ignore(ignored_abspaths)
|
486
|
+
end
|
487
|
+
|
360
488
|
def colorize_logging
|
361
489
|
ActiveSupport::LogSubscriber.colorize_logging
|
362
490
|
end
|
@@ -367,8 +495,9 @@ module Rails
|
|
367
495
|
end
|
368
496
|
|
369
497
|
# 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
|
498
|
+
# are +:cache_store+, +:cookie_store+, +:mem_cache_store+, a custom
|
499
|
+
# store, or +:disabled+. +:disabled+ tells \Rails not to deal with
|
500
|
+
# sessions.
|
372
501
|
#
|
373
502
|
# Additional options will be set as +session_options+:
|
374
503
|
#
|
@@ -382,25 +511,14 @@ module Rails
|
|
382
511
|
# config.session_store :my_custom_store
|
383
512
|
def session_store(new_session_store = nil, **options)
|
384
513
|
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
514
|
@session_store = new_session_store
|
395
515
|
@session_options = options || {}
|
396
516
|
else
|
397
517
|
case @session_store
|
398
518
|
when :disabled
|
399
519
|
nil
|
400
|
-
when :active_record_store
|
401
|
-
ActionDispatch::Session::ActiveRecordStore
|
402
520
|
when Symbol
|
403
|
-
ActionDispatch::Session.
|
521
|
+
ActionDispatch::Session.resolve_store(@session_store)
|
404
522
|
else
|
405
523
|
@session_store
|
406
524
|
end
|
@@ -445,6 +563,10 @@ module Rails
|
|
445
563
|
f
|
446
564
|
end
|
447
565
|
|
566
|
+
def inspect # :nodoc:
|
567
|
+
"#<#{self.class.name}:#{'%#016x' % (object_id << 1)}>"
|
568
|
+
end
|
569
|
+
|
448
570
|
class Custom # :nodoc:
|
449
571
|
def initialize
|
450
572
|
@configurations = Hash.new
|
@@ -466,24 +588,14 @@ module Rails
|
|
466
588
|
end
|
467
589
|
|
468
590
|
private
|
469
|
-
def
|
470
|
-
|
471
|
-
|
472
|
-
else
|
473
|
-
root.join("config", "credentials.yml.enc")
|
474
|
-
end
|
475
|
-
end
|
591
|
+
def credentials_defaults
|
592
|
+
content_path = root.join("config/credentials/#{Rails.env}.yml.enc")
|
593
|
+
content_path = root.join("config/credentials.yml.enc") if !content_path.exist?
|
476
594
|
|
477
|
-
|
478
|
-
if
|
479
|
-
root.join("config", "credentials", "#{Rails.env}.key")
|
480
|
-
else
|
481
|
-
root.join("config", "master.key")
|
482
|
-
end
|
483
|
-
end
|
595
|
+
key_path = root.join("config/credentials/#{Rails.env}.key")
|
596
|
+
key_path = root.join("config/master.key") if !key_path.exist?
|
484
597
|
|
485
|
-
|
486
|
-
File.exist?(root.join("config", "credentials", "#{Rails.env}.yml.enc"))
|
598
|
+
{ content_path: content_path, key_path: key_path }
|
487
599
|
end
|
488
600
|
end
|
489
601
|
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
|
@@ -169,6 +172,7 @@ module Rails
|
|
169
172
|
# some sort of reloaders dependency support, to be added.
|
170
173
|
require_unload_lock!
|
171
174
|
reloader.execute
|
175
|
+
ActiveSupport.run_load_hooks(:after_routes_loaded, self)
|
172
176
|
end
|
173
177
|
end
|
174
178
|
|
@@ -181,39 +185,42 @@ module Rails
|
|
181
185
|
ActiveSupport::Dependencies.clear
|
182
186
|
end
|
183
187
|
|
184
|
-
if config.
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
188
|
+
if config.reloading_enabled?
|
189
|
+
if config.reload_classes_only_on_change
|
190
|
+
app.reloader.check = lambda do
|
191
|
+
app.reloaders.map(&:updated?).any?
|
192
|
+
end
|
193
|
+
else
|
194
|
+
app.reloader.check = lambda { true }
|
189
195
|
end
|
190
196
|
else
|
191
|
-
app.reloader.check = lambda {
|
197
|
+
app.reloader.check = lambda { false }
|
192
198
|
end
|
193
199
|
|
194
|
-
if config.
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
200
|
+
if config.reloading_enabled?
|
201
|
+
if config.reload_classes_only_on_change
|
202
|
+
reloader = config.file_watcher.new(*watchable_args, &callback)
|
203
|
+
reloaders << reloader
|
204
|
+
|
205
|
+
# Prepend this callback to have autoloaded constants cleared before
|
206
|
+
# any other possible reloading, in case they need to autoload fresh
|
207
|
+
# constants.
|
208
|
+
app.reloader.to_run(prepend: true) do
|
209
|
+
# In addition to changes detected by the file watcher, if routes
|
210
|
+
# or i18n have been updated we also need to clear constants,
|
211
|
+
# that's why we run #execute rather than #execute_if_updated, this
|
212
|
+
# callback has to clear autoloaded constants after any update.
|
213
|
+
class_unload! do
|
214
|
+
reloader.execute
|
215
|
+
end
|
216
|
+
end
|
217
|
+
else
|
218
|
+
app.reloader.to_complete do
|
219
|
+
class_unload!(&callback)
|
211
220
|
end
|
212
221
|
end
|
213
222
|
else
|
214
|
-
|
215
|
-
class_unload!(&callback)
|
216
|
-
end
|
223
|
+
ActiveSupport::DescendantsTracker.disable_clear!
|
217
224
|
end
|
218
225
|
end
|
219
226
|
end
|