railties 7.1.3.4 → 8.0.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 +128 -775
- data/lib/minitest/rails_plugin.rb +6 -3
- data/lib/rails/all.rb +1 -3
- data/lib/rails/api/task.rb +6 -4
- data/lib/rails/application/bootstrap.rb +5 -7
- data/lib/rails/application/configuration.rb +81 -43
- data/lib/rails/application/default_middleware_stack.rb +4 -0
- data/lib/rails/application/dummy_config.rb +2 -2
- data/lib/rails/application/finisher.rb +9 -3
- data/lib/rails/application/routes_reloader.rb +16 -2
- data/lib/rails/application.rb +27 -86
- data/lib/rails/backtrace_cleaner.rb +19 -4
- data/lib/rails/cli.rb +0 -1
- data/lib/rails/code_statistics.rb +128 -86
- data/lib/rails/code_statistics_calculator.rb +78 -76
- data/lib/rails/command/helpers/editor.rb +1 -1
- data/lib/rails/command.rb +0 -6
- data/lib/rails/commands/app/update_command.rb +94 -0
- data/lib/rails/commands/boot/boot_command.rb +14 -0
- data/lib/rails/commands/console/console_command.rb +2 -21
- data/lib/rails/commands/console/irb_console.rb +128 -0
- data/lib/rails/commands/credentials/USAGE +4 -4
- data/lib/rails/commands/credentials/credentials_command.rb +7 -3
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +21 -30
- data/lib/rails/commands/dev/dev_command.rb +1 -1
- data/lib/rails/commands/devcontainer/devcontainer_command.rb +40 -0
- data/lib/rails/commands/rake/rake_command.rb +1 -1
- data/lib/rails/commands/runner/runner_command.rb +14 -3
- data/lib/rails/commands/server/server_command.rb +5 -3
- data/lib/rails/commands/stats/stats_command.rb +19 -0
- data/lib/rails/commands/test/test_command.rb +2 -0
- data/lib/rails/configuration.rb +10 -1
- data/lib/rails/console/methods.rb +7 -0
- data/lib/rails/dev_caching.rb +2 -2
- data/lib/rails/engine/configuration.rb +3 -1
- data/lib/rails/engine/lazy_route_set.rb +114 -0
- data/lib/rails/engine.rb +16 -12
- data/lib/rails/gem_version.rb +4 -4
- data/lib/rails/generators/actions.rb +3 -3
- data/lib/rails/generators/app_base.rb +115 -68
- data/lib/rails/generators/base.rb +1 -1
- data/lib/rails/generators/database.rb +263 -71
- data/lib/rails/generators/erb/authentication/authentication_generator.rb +15 -0
- data/lib/rails/generators/erb/authentication/templates/app/views/passwords/edit.html.erb +9 -0
- data/lib/rails/generators/erb/authentication/templates/app/views/passwords/new.html.erb +8 -0
- data/lib/rails/generators/erb/authentication/templates/app/views/sessions/new.html.erb +11 -0
- 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 +42 -12
- data/lib/rails/generators/migration.rb +3 -3
- data/lib/rails/generators/rails/app/app_generator.rb +75 -54
- data/lib/rails/generators/rails/app/templates/Dockerfile.tt +33 -17
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +38 -23
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css.tt +6 -11
- 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 +17 -3
- 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/dev.tt +1 -0
- data/lib/rails/generators/rails/app/templates/bin/rubocop.tt +7 -0
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +6 -5
- data/lib/rails/generators/rails/app/templates/bin/thrust.tt +4 -0
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +26 -3
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +30 -0
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +47 -0
- data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +26 -3
- data/lib/rails/generators/rails/app/templates/config/deploy.yml.tt +128 -0
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +22 -26
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +36 -48
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +7 -18
- data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +0 -7
- data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_8_0.rb.tt +30 -0
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +35 -27
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +6 -0
- data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +7 -1
- data/lib/rails/generators/rails/app/templates/dockerignore.tt +20 -2
- data/lib/rails/generators/rails/app/templates/github/ci.yml.tt +144 -0
- data/lib/rails/generators/rails/app/templates/github/dependabot.yml +12 -0
- data/lib/rails/generators/rails/app/templates/gitignore.tt +4 -5
- data/lib/rails/generators/rails/app/templates/kamal-secrets.tt +17 -0
- data/lib/rails/generators/rails/app/templates/public/400.html +114 -0
- data/lib/rails/generators/rails/app/templates/public/404.html +113 -66
- data/lib/rails/generators/rails/app/templates/public/406-unsupported-browser.html +114 -0
- data/lib/rails/generators/rails/app/templates/public/422.html +113 -66
- data/lib/rails/generators/rails/app/templates/public/500.html +113 -65
- 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/authentication/USAGE +6 -0
- data/lib/rails/generators/rails/authentication/authentication_generator.rb +58 -0
- data/lib/rails/generators/rails/authentication/templates/app/channels/application_cable/connection.rb.tt +16 -0
- data/lib/rails/generators/rails/authentication/templates/app/controllers/concerns/authentication.rb.tt +52 -0
- data/lib/rails/generators/rails/authentication/templates/app/controllers/passwords_controller.rb.tt +33 -0
- data/lib/rails/generators/rails/authentication/templates/app/controllers/sessions_controller.rb.tt +21 -0
- data/lib/rails/generators/rails/authentication/templates/app/mailers/passwords_mailer.rb.tt +6 -0
- data/lib/rails/generators/rails/authentication/templates/app/models/current.rb.tt +4 -0
- data/lib/rails/generators/rails/authentication/templates/app/models/session.rb.tt +3 -0
- data/lib/rails/generators/rails/authentication/templates/app/models/user.rb.tt +6 -0
- data/lib/rails/generators/rails/authentication/templates/app/views/passwords_mailer/reset.html.erb.tt +4 -0
- data/lib/rails/generators/rails/authentication/templates/app/views/passwords_mailer/reset.text.erb.tt +2 -0
- data/lib/rails/generators/rails/authentication/templates/test/mailers/previews/passwords_mailer_preview.rb.tt +7 -0
- data/lib/rails/generators/rails/controller/controller_generator.rb +1 -1
- data/lib/rails/generators/rails/credentials/templates/credentials.yml.tt +4 -0
- data/lib/rails/generators/rails/db/system/change/change_generator.rb +132 -21
- data/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb +176 -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/migration/migration_generator.rb +4 -0
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +47 -16
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +2 -2
- data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +6 -2
- 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/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/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 +2 -2
- data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +2 -2
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +3 -3
- data/lib/rails/generators/rails/script/USAGE +18 -0
- data/lib/rails/generators/rails/script/script_generator.rb +18 -0
- data/lib/rails/generators/rails/script/templates/script.rb.tt +3 -0
- data/lib/rails/generators/test_unit/authentication/authentication_generator.rb +14 -0
- data/lib/rails/generators/test_unit/authentication/templates/test/fixtures/users.yml.tt +9 -0
- data/lib/rails/generators/test_unit/authentication/templates/test/models/user_test.rb.tt +7 -0
- 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 +15 -1
- 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/behavior.rb +7 -6
- data/lib/rails/generators.rb +7 -2
- data/lib/rails/health_controller.rb +1 -1
- data/lib/rails/info.rb +2 -2
- data/lib/rails/info_controller.rb +10 -2
- data/lib/rails/mailers_controller.rb +14 -1
- data/lib/rails/paths.rb +2 -2
- data/lib/rails/pwa_controller.rb +15 -0
- data/lib/rails/rack/logger.rb +15 -7
- data/lib/rails/rack/silence_request.rb +33 -0
- data/lib/rails/rack.rb +1 -0
- data/lib/rails/railtie/configurable.rb +2 -2
- data/lib/rails/railtie.rb +15 -16
- data/lib/rails/source_annotation_extractor.rb +31 -14
- data/lib/rails/tasks/framework.rake +0 -26
- data/lib/rails/tasks/statistics.rake +13 -28
- data/lib/rails/tasks/tmp.rake +1 -1
- data/lib/rails/templates/layouts/application.html.erb +1 -1
- data/lib/rails/templates/rails/info/notes.html.erb +65 -0
- data/lib/rails/templates/rails/mailers/email.html.erb +12 -8
- data/lib/rails/templates/rails/welcome/index.html.erb +4 -2
- data/lib/rails/test_help.rb +2 -4
- data/lib/rails/test_unit/reporter.rb +8 -2
- data/lib/rails/test_unit/runner.rb +27 -2
- data/lib/rails/test_unit/test_parser.rb +48 -0
- data/lib/rails.rb +7 -4
- metadata +77 -45
- data/lib/rails/app_updater.rb +0 -40
- data/lib/rails/commands/secrets/USAGE +0 -61
- data/lib/rails/commands/secrets/secrets_command.rb +0 -47
- data/lib/rails/console/app.rb +0 -35
- data/lib/rails/console/helpers.rb +0 -19
- data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +0 -2
- data/lib/rails/generators/rails/app/templates/app/channels/application_cable/channel.rb.tt +0 -4
- data/lib/rails/generators/rails/app/templates/app/channels/application_cable/connection.rb.tt +0 -4
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +0 -68
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +0 -54
- 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_1.rb.tt +0 -284
- data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +0 -13
- 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/app/templates/test/channels/application_cable/connection_test.rb.tt +0 -13
- data/lib/rails/generators/rails/plugin/templates/rails/dummy_manifest.js.tt +0 -10
- data/lib/rails/generators/rails/plugin/templates/rails/engine_manifest.js.tt +0 -6
- data/lib/rails/generators/rails/plugin/templates/rails/javascripts.js.tt +0 -17
- data/lib/rails/ruby_version_check.rb +0 -17
- data/lib/rails/secrets.rb +0 -110
@@ -25,7 +25,7 @@ module Minitest
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
class ProfileReporter <
|
28
|
+
class ProfileReporter < Reporter
|
29
29
|
def initialize(io = $stdout, options = {})
|
30
30
|
super
|
31
31
|
@results = []
|
@@ -94,7 +94,7 @@ module Minitest
|
|
94
94
|
if count.nil?
|
95
95
|
warn("Non integer specified as profile count, separate " \
|
96
96
|
"your path from options with -- e.g. " \
|
97
|
-
"
|
97
|
+
"`#{::Rails::TestUnitReporter.executable} --profile -- #{value}`")
|
98
98
|
count = default_count
|
99
99
|
end
|
100
100
|
end
|
@@ -109,7 +109,10 @@ module Minitest
|
|
109
109
|
# Owes great inspiration to test runner trailblazers like RSpec,
|
110
110
|
# minitest-reporters, maxitest, and others.
|
111
111
|
def self.plugin_rails_init(options)
|
112
|
-
unless
|
112
|
+
# Don't mess with Minitest unless RAILS_ENV is set
|
113
|
+
return unless ENV["RAILS_ENV"] || ENV["RAILS_MINITEST_PLUGIN"]
|
114
|
+
|
115
|
+
unless options[:full_backtrace]
|
113
116
|
# Plugin can run without Rails loaded, check before filtering.
|
114
117
|
if ::Rails.respond_to?(:backtrace_cleaner)
|
115
118
|
Minitest.backtrace_filter = BacktraceFilterWithFallback.new(::Rails.backtrace_cleaner, Minitest.backtrace_filter)
|
data/lib/rails/all.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Style/RedundantBegin
|
4
|
-
|
5
3
|
require "rails"
|
6
4
|
|
7
5
|
%w(
|
@@ -16,7 +14,7 @@ require "rails"
|
|
16
14
|
action_text/engine
|
17
15
|
rails/test_unit/railtie
|
18
16
|
).each do |railtie|
|
19
|
-
begin
|
17
|
+
begin # rubocop:disable Style/RedundantBegin
|
20
18
|
require railtie
|
21
19
|
rescue LoadError
|
22
20
|
end
|
data/lib/rails/api/task.rb
CHANGED
@@ -146,8 +146,6 @@ module Rails
|
|
146
146
|
end
|
147
147
|
|
148
148
|
def configure_rdoc_files
|
149
|
-
rdoc_files.include(api_main)
|
150
|
-
|
151
149
|
RDOC_FILES.each do |component, cfg|
|
152
150
|
cdr = component_root_dir(component)
|
153
151
|
|
@@ -162,8 +160,9 @@ module Rails
|
|
162
160
|
|
163
161
|
# Only generate documentation for files that have been
|
164
162
|
# changed since the API was generated.
|
165
|
-
|
166
|
-
|
163
|
+
timestamp_path = "#{api_dir}/created.rid"
|
164
|
+
if File.exist?(timestamp_path) && !File.zero?(timestamp_path) && !ENV["ALL"]
|
165
|
+
last_generation = DateTime.rfc2822(File.open(timestamp_path, &:readline))
|
167
166
|
|
168
167
|
rdoc_files.keep_if do |file|
|
169
168
|
File.mtime(file).to_datetime > last_generation
|
@@ -172,6 +171,9 @@ module Rails
|
|
172
171
|
# Nothing to do
|
173
172
|
exit(0) if rdoc_files.empty?
|
174
173
|
end
|
174
|
+
|
175
|
+
# This must come after the mtime comparison to ensure the main page is not excluded.
|
176
|
+
rdoc_files.include(api_main)
|
175
177
|
end
|
176
178
|
|
177
179
|
# These variables are used by the sdoc template
|
@@ -1,11 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "fileutils"
|
4
|
-
require "set"
|
5
4
|
require "active_support/notifications"
|
6
5
|
require "active_support/dependencies"
|
7
6
|
require "active_support/descendants_tracker"
|
8
|
-
require "rails/secrets"
|
9
7
|
|
10
8
|
module Rails
|
11
9
|
class Application
|
@@ -65,8 +63,12 @@ module Rails
|
|
65
63
|
broadcast_logger.formatter = Rails.logger.formatter
|
66
64
|
Rails.logger = broadcast_logger
|
67
65
|
end
|
66
|
+
end
|
68
67
|
|
69
|
-
|
68
|
+
initializer :initialize_error_reporter, group: :all do
|
69
|
+
if config.consider_all_requests_local
|
70
|
+
Rails.error.debug_mode = true
|
71
|
+
else
|
70
72
|
Rails.error.logger = Rails.logger
|
71
73
|
end
|
72
74
|
end
|
@@ -110,10 +112,6 @@ module Rails
|
|
110
112
|
initializer :bootstrap_hook, group: :all do |app|
|
111
113
|
ActiveSupport.run_load_hooks(:before_initialize, app)
|
112
114
|
end
|
113
|
-
|
114
|
-
initializer :set_secrets_root, group: :all do
|
115
|
-
Rails::Secrets.root = root
|
116
|
-
end
|
117
115
|
end
|
118
116
|
end
|
119
117
|
end
|
@@ -15,15 +15,15 @@ module Rails
|
|
15
15
|
:cache_classes, :cache_store, :consider_all_requests_local, :console,
|
16
16
|
:eager_load, :exceptions_app, :file_watcher, :filter_parameters, :precompile_filter_parameters,
|
17
17
|
:force_ssl, :helpers_paths, :hosts, :host_authorization, :logger, :log_formatter,
|
18
|
-
:log_tags, :
|
18
|
+
:log_tags, :silence_healthcheck_path, :railties_order, :relative_url_root,
|
19
19
|
:ssl_options, :public_file_server,
|
20
20
|
:session_options, :time_zone, :reload_classes_only_on_change,
|
21
21
|
:beginning_of_week, :filter_redirect, :x,
|
22
|
-
:
|
22
|
+
:content_security_policy_report_only,
|
23
23
|
:content_security_policy_nonce_generator, :content_security_policy_nonce_directives,
|
24
24
|
:require_master_key, :credentials, :disable_sandbox, :sandbox_by_default,
|
25
25
|
:add_autoload_paths_to_load_path, :rake_eager_load, :server_timing, :log_file_size,
|
26
|
-
:dom_testing_default_html_version
|
26
|
+
:dom_testing_default_html_version, :yjit
|
27
27
|
|
28
28
|
attr_reader :encoding, :api_only, :loaded_config_version, :log_level
|
29
29
|
|
@@ -62,13 +62,12 @@ module Rails
|
|
62
62
|
@exceptions_app = nil
|
63
63
|
@autoflush_log = true
|
64
64
|
@log_formatter = ActiveSupport::Logger::SimpleFormatter.new
|
65
|
+
@silence_healthcheck_path = nil
|
65
66
|
@eager_load = nil
|
66
67
|
@secret_key_base = nil
|
67
68
|
@api_only = false
|
68
69
|
@debug_exception_response_format = nil
|
69
70
|
@x = Custom.new
|
70
|
-
@enable_dependency_loading = false
|
71
|
-
@read_encrypted_secrets = false
|
72
71
|
@content_security_policy = nil
|
73
72
|
@content_security_policy_report_only = false
|
74
73
|
@content_security_policy_nonce_generator = nil
|
@@ -83,6 +82,7 @@ module Rails
|
|
83
82
|
@rake_eager_load = false
|
84
83
|
@server_timing = false
|
85
84
|
@dom_testing_default_html_version = :html4
|
85
|
+
@yjit = false
|
86
86
|
end
|
87
87
|
|
88
88
|
# Loads default configuration values for a target version. This includes
|
@@ -115,7 +115,9 @@ module Rails
|
|
115
115
|
action_controller.forgery_protection_origin_check = true
|
116
116
|
end
|
117
117
|
|
118
|
-
|
118
|
+
if respond_to?(:active_support)
|
119
|
+
active_support.to_time_preserves_timezone = :offset
|
120
|
+
end
|
119
121
|
|
120
122
|
if respond_to?(:active_record)
|
121
123
|
active_record.belongs_to_required_by_default = true
|
@@ -279,8 +281,6 @@ module Rails
|
|
279
281
|
|
280
282
|
if respond_to?(:active_record)
|
281
283
|
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
284
|
active_record.sqlite3_adapter_strict_strings_by_default = true
|
285
285
|
active_record.query_log_tags_format = :sqlcommenter
|
286
286
|
active_record.raise_on_assign_to_attr_readonly = true
|
@@ -305,10 +305,6 @@ module Rails
|
|
305
305
|
action_dispatch.debug_exception_log_level = :error
|
306
306
|
end
|
307
307
|
|
308
|
-
if respond_to?(:active_job)
|
309
|
-
active_job.use_big_decimal_serializer = true
|
310
|
-
end
|
311
|
-
|
312
308
|
if respond_to?(:active_support)
|
313
309
|
active_support.cache_format_version = 7.1
|
314
310
|
active_support.message_serializer = :json_allow_marshal
|
@@ -316,19 +312,40 @@ module Rails
|
|
316
312
|
active_support.raise_on_invalid_cache_expiration_time = true
|
317
313
|
end
|
318
314
|
|
319
|
-
if respond_to?(:
|
320
|
-
|
315
|
+
if respond_to?(:action_view)
|
316
|
+
require "action_view/helpers"
|
317
|
+
action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
|
321
318
|
end
|
322
319
|
|
323
|
-
if
|
324
|
-
|
325
|
-
|
326
|
-
|
320
|
+
if respond_to?(:action_text)
|
321
|
+
require "action_view/helpers"
|
322
|
+
action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
|
323
|
+
end
|
324
|
+
when "7.2"
|
325
|
+
load_defaults "7.1"
|
327
326
|
|
328
|
-
|
329
|
-
|
330
|
-
|
327
|
+
self.yjit = true
|
328
|
+
|
329
|
+
if respond_to?(:active_storage)
|
330
|
+
active_storage.web_image_content_types = %w( image/png image/jpeg image/gif image/webp )
|
331
331
|
end
|
332
|
+
|
333
|
+
if respond_to?(:active_record)
|
334
|
+
active_record.postgresql_adapter_decode_dates = true
|
335
|
+
active_record.validate_migration_timestamps = true
|
336
|
+
end
|
337
|
+
when "8.0"
|
338
|
+
load_defaults "7.2"
|
339
|
+
|
340
|
+
if respond_to?(:active_support)
|
341
|
+
active_support.to_time_preserves_timezone = :zone
|
342
|
+
end
|
343
|
+
|
344
|
+
if respond_to?(:action_dispatch)
|
345
|
+
action_dispatch.strict_freshness = true
|
346
|
+
end
|
347
|
+
|
348
|
+
Regexp.timeout ||= 1 if Regexp.respond_to?(:timeout=)
|
332
349
|
else
|
333
350
|
raise "Unknown version #{target_version.to_s.inspect}"
|
334
351
|
end
|
@@ -348,22 +365,6 @@ module Rails
|
|
348
365
|
self.cache_classes = !value
|
349
366
|
end
|
350
367
|
|
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
|
-
|
367
368
|
def encoding=(value)
|
368
369
|
@encoding = value
|
369
370
|
silence_warnings do
|
@@ -384,9 +385,7 @@ module Rails
|
|
384
385
|
@broadcast_log_level = level
|
385
386
|
end
|
386
387
|
|
387
|
-
|
388
|
-
defined?(@broadcast_log_level) ? @broadcast_log_level : nil
|
389
|
-
end
|
388
|
+
attr_reader :broadcast_log_level # :nodoc:
|
390
389
|
|
391
390
|
def debug_exception_response_format
|
392
391
|
@debug_exception_response_format || :default
|
@@ -398,7 +397,6 @@ module Rails
|
|
398
397
|
@paths ||= begin
|
399
398
|
paths = super
|
400
399
|
paths.add "config/database", with: "config/database.yml"
|
401
|
-
paths.add "config/secrets", with: "config", glob: "secrets.yml{,.enc}"
|
402
400
|
paths.add "config/environment", with: "config/environment.rb"
|
403
401
|
paths.add "lib/templates"
|
404
402
|
paths.add "log", with: "log/#{Rails.env}.log"
|
@@ -503,6 +501,28 @@ module Rails
|
|
503
501
|
generators.colorize_logging = val
|
504
502
|
end
|
505
503
|
|
504
|
+
def secret_key_base
|
505
|
+
@secret_key_base || begin
|
506
|
+
self.secret_key_base = if generate_local_secret?
|
507
|
+
generate_local_secret
|
508
|
+
else
|
509
|
+
ENV["SECRET_KEY_BASE"] || Rails.application.credentials.secret_key_base
|
510
|
+
end
|
511
|
+
end
|
512
|
+
end
|
513
|
+
|
514
|
+
def secret_key_base=(new_secret_key_base)
|
515
|
+
if new_secret_key_base.nil? && generate_local_secret?
|
516
|
+
@secret_key_base = generate_local_secret
|
517
|
+
elsif new_secret_key_base.is_a?(String) && new_secret_key_base.present?
|
518
|
+
@secret_key_base = new_secret_key_base
|
519
|
+
elsif new_secret_key_base
|
520
|
+
raise ArgumentError, "`secret_key_base` for #{Rails.env} environment must be a type of String`"
|
521
|
+
else
|
522
|
+
raise ArgumentError, "Missing `secret_key_base` for '#{Rails.env}' environment, set this string with `bin/rails credentials:edit`"
|
523
|
+
end
|
524
|
+
end
|
525
|
+
|
506
526
|
# Specifies what class to use to store the session. Possible values
|
507
527
|
# are +:cache_store+, +:cookie_store+, +:mem_cache_store+, a custom
|
508
528
|
# store, or +:disabled+. +:disabled+ tells \Rails not to deal with
|
@@ -584,14 +604,16 @@ module Rails
|
|
584
604
|
def method_missing(method, *args)
|
585
605
|
if method.end_with?("=")
|
586
606
|
@configurations[:"#{method[0..-2]}"] = args.first
|
587
|
-
|
607
|
+
elsif args.empty?
|
588
608
|
@configurations.fetch(method) {
|
589
609
|
@configurations[method] = ActiveSupport::OrderedOptions.new
|
590
610
|
}
|
611
|
+
else
|
612
|
+
raise ArgumentError, "wrong number of arguments (given #{args.length}, expected 0) when reading configuration `#{method}`"
|
591
613
|
end
|
592
614
|
end
|
593
615
|
|
594
|
-
def respond_to_missing?(symbol,
|
616
|
+
def respond_to_missing?(symbol, _)
|
595
617
|
true
|
596
618
|
end
|
597
619
|
end
|
@@ -606,6 +628,22 @@ module Rails
|
|
606
628
|
|
607
629
|
{ content_path: content_path, key_path: key_path }
|
608
630
|
end
|
631
|
+
|
632
|
+
def generate_local_secret
|
633
|
+
key_file = root.join("tmp/local_secret.txt")
|
634
|
+
|
635
|
+
unless File.exist?(key_file)
|
636
|
+
random_key = SecureRandom.hex(64)
|
637
|
+
FileUtils.mkdir_p(key_file.dirname)
|
638
|
+
File.binwrite(key_file, random_key)
|
639
|
+
end
|
640
|
+
|
641
|
+
File.binread(key_file)
|
642
|
+
end
|
643
|
+
|
644
|
+
def generate_local_secret?
|
645
|
+
Rails.env.local? || ENV["SECRET_KEY_BASE_DUMMY"]
|
646
|
+
end
|
609
647
|
end
|
610
648
|
end
|
611
649
|
end
|
@@ -54,6 +54,10 @@ module Rails
|
|
54
54
|
middleware.use ::ActionDispatch::RequestId, header: config.action_dispatch.request_id_header
|
55
55
|
middleware.use ::ActionDispatch::RemoteIp, config.action_dispatch.ip_spoofing_check, config.action_dispatch.trusted_proxies
|
56
56
|
|
57
|
+
if path = config.silence_healthcheck_path
|
58
|
+
middleware.use ::Rails::Rack::SilenceRequest, path: path
|
59
|
+
end
|
60
|
+
|
57
61
|
middleware.use ::Rails::Rack::Logger, config.log_tags
|
58
62
|
middleware.use ::ActionDispatch::ShowExceptions, show_exceptions_app
|
59
63
|
middleware.use ::ActionDispatch::DebugExceptions, app, config.debug_exception_response_format
|
@@ -9,9 +9,9 @@ class DummyConfig # :nodoc:
|
|
9
9
|
"DummyConfig"
|
10
10
|
end
|
11
11
|
|
12
|
-
def method_missing(selector,
|
12
|
+
def method_missing(selector, ...)
|
13
13
|
if @config.respond_to?(selector)
|
14
|
-
@config.send(selector,
|
14
|
+
@config.send(selector, ...)
|
15
15
|
else
|
16
16
|
self
|
17
17
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "set"
|
4
3
|
require "active_support/core_ext/string/inflections"
|
5
4
|
require "active_support/core_ext/array/conversions"
|
6
5
|
require "active_support/descendants_tracker"
|
@@ -78,6 +77,7 @@ module Rails
|
|
78
77
|
if config.eager_load
|
79
78
|
ActiveSupport.run_load_hooks(:before_eager_load, self)
|
80
79
|
Zeitwerk::Loader.eager_load_all
|
80
|
+
Rails.eager_load!
|
81
81
|
config.eager_load_namespaces.each(&:eager_load!)
|
82
82
|
|
83
83
|
if config.reloading_enabled?
|
@@ -142,6 +142,7 @@ module Rails
|
|
142
142
|
app.routes.prepend do
|
143
143
|
get "/rails/info/properties" => "rails/info#properties", internal: true
|
144
144
|
get "/rails/info/routes" => "rails/info#routes", internal: true
|
145
|
+
get "/rails/info/notes" => "rails/info#notes", internal: true
|
145
146
|
get "/rails/info" => "rails/info#index", internal: true
|
146
147
|
end
|
147
148
|
|
@@ -158,7 +159,6 @@ module Rails
|
|
158
159
|
initializer :set_routes_reloader_hook do |app|
|
159
160
|
reloader = routes_reloader
|
160
161
|
reloader.eager_load = app.config.eager_load
|
161
|
-
reloader.execute
|
162
162
|
reloaders << reloader
|
163
163
|
|
164
164
|
app.reloader.to_run do
|
@@ -176,7 +176,7 @@ module Rails
|
|
176
176
|
ActiveSupport.run_load_hooks(:after_routes_loaded, self)
|
177
177
|
end
|
178
178
|
|
179
|
-
|
179
|
+
reloader.execute_unless_loaded if !app.routes.is_a?(Engine::LazyRouteSet) || app.config.eager_load
|
180
180
|
end
|
181
181
|
|
182
182
|
# Set clearing dependencies after the finisher hook to ensure paths
|
@@ -226,6 +226,12 @@ module Rails
|
|
226
226
|
ActiveSupport::DescendantsTracker.disable_clear!
|
227
227
|
end
|
228
228
|
end
|
229
|
+
|
230
|
+
initializer :enable_yjit do
|
231
|
+
if config.yjit && defined?(RubyVM::YJIT.enable)
|
232
|
+
RubyVM::YJIT.enable
|
233
|
+
end
|
234
|
+
end
|
229
235
|
end
|
230
236
|
end
|
231
237
|
end
|
@@ -7,16 +7,17 @@ module Rails
|
|
7
7
|
class RoutesReloader
|
8
8
|
include ActiveSupport::Callbacks
|
9
9
|
|
10
|
-
attr_reader :route_sets, :paths, :external_routes
|
10
|
+
attr_reader :route_sets, :paths, :external_routes, :loaded
|
11
11
|
attr_accessor :eager_load
|
12
12
|
attr_writer :run_after_load_paths # :nodoc:
|
13
|
-
delegate :execute_if_updated, :
|
13
|
+
delegate :execute_if_updated, :updated?, to: :updater
|
14
14
|
|
15
15
|
def initialize
|
16
16
|
@paths = []
|
17
17
|
@route_sets = []
|
18
18
|
@external_routes = []
|
19
19
|
@eager_load = false
|
20
|
+
@loaded = false
|
20
21
|
end
|
21
22
|
|
22
23
|
def reload!
|
@@ -28,6 +29,19 @@ module Rails
|
|
28
29
|
revert
|
29
30
|
end
|
30
31
|
|
32
|
+
def execute
|
33
|
+
@loaded = true
|
34
|
+
updater.execute
|
35
|
+
end
|
36
|
+
|
37
|
+
def execute_unless_loaded
|
38
|
+
unless @loaded
|
39
|
+
execute
|
40
|
+
ActiveSupport.run_load_hooks(:after_routes_loaded, Rails.application)
|
41
|
+
true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
31
45
|
private
|
32
46
|
def updater
|
33
47
|
@updater ||= begin
|
data/lib/rails/application.rb
CHANGED
@@ -9,8 +9,8 @@ require "active_support/deprecation"
|
|
9
9
|
require "active_support/encrypted_configuration"
|
10
10
|
require "active_support/hash_with_indifferent_access"
|
11
11
|
require "active_support/configuration_file"
|
12
|
+
require "active_support/parameter_filter"
|
12
13
|
require "rails/engine"
|
13
|
-
require "rails/secrets"
|
14
14
|
require "rails/autoloaders"
|
15
15
|
|
16
16
|
module Rails
|
@@ -104,7 +104,7 @@ module Rails
|
|
104
104
|
delegate :default_url_options, :default_url_options=, to: :routes
|
105
105
|
|
106
106
|
INITIAL_VARIABLES = [:config, :railties, :routes_reloader, :reloaders,
|
107
|
-
:routes, :helpers, :app_env_config
|
107
|
+
:routes, :helpers, :app_env_config] # :nodoc:
|
108
108
|
|
109
109
|
def initialize(initial_variable_values = {}, &block)
|
110
110
|
super()
|
@@ -135,6 +135,13 @@ module Rails
|
|
135
135
|
@initialized
|
136
136
|
end
|
137
137
|
|
138
|
+
# Returns the dasherized application name.
|
139
|
+
#
|
140
|
+
# MyApp::Application.new.name => "my-app"
|
141
|
+
def name
|
142
|
+
self.class.name.underscore.dasherize.delete_suffix("/application")
|
143
|
+
end
|
144
|
+
|
138
145
|
def run_load_hooks! # :nodoc:
|
139
146
|
return self if @ran_load_hooks
|
140
147
|
@ran_load_hooks = true
|
@@ -154,6 +161,10 @@ module Rails
|
|
154
161
|
routes_reloader.reload!
|
155
162
|
end
|
156
163
|
|
164
|
+
def reload_routes_unless_loaded # :nodoc:
|
165
|
+
initialized? && routes_reloader.execute_unless_loaded
|
166
|
+
end
|
167
|
+
|
157
168
|
# Returns a key generator (ActiveSupport::CachingKeyGenerator) for a
|
158
169
|
# specified +secret_key_base+. The return value is memoized, so additional
|
159
170
|
# calls with the same +secret_key_base+ will return the same key generator
|
@@ -208,17 +219,20 @@ module Rails
|
|
208
219
|
# It is recommended not to use the same verifier for different things, so you can get different
|
209
220
|
# verifiers passing the +verifier_name+ argument.
|
210
221
|
#
|
222
|
+
# For instance, +ActiveStorage::Blob.signed_id_verifier+ is implemented using this feature, which assures that
|
223
|
+
# the IDs strings haven't been tampered with and are safe to use in a finder.
|
224
|
+
#
|
225
|
+
# See the ActiveSupport::MessageVerifier documentation for more information.
|
226
|
+
#
|
211
227
|
# ==== Parameters
|
212
228
|
#
|
213
229
|
# * +verifier_name+ - the name of the message verifier.
|
214
230
|
#
|
215
231
|
# ==== Examples
|
216
232
|
#
|
217
|
-
# message = Rails.application.message_verifier('
|
218
|
-
# Rails.application.message_verifier('
|
219
|
-
# # => '
|
220
|
-
#
|
221
|
-
# See the ActiveSupport::MessageVerifier documentation for more information.
|
233
|
+
# message = Rails.application.message_verifier('my_purpose').generate('data to sign against tampering')
|
234
|
+
# Rails.application.message_verifier('my_purpose').verify(message)
|
235
|
+
# # => 'data to sign against tampering'
|
222
236
|
def message_verifier(verifier_name)
|
223
237
|
message_verifiers[verifier_name]
|
224
238
|
end
|
@@ -412,8 +426,8 @@ module Rails
|
|
412
426
|
def watchable_args # :nodoc:
|
413
427
|
files, dirs = config.watchable_files.dup, config.watchable_dirs.dup
|
414
428
|
|
415
|
-
|
416
|
-
|
429
|
+
Rails.autoloaders.main.dirs.each do |path|
|
430
|
+
dirs[path] = [:rb]
|
417
431
|
end
|
418
432
|
|
419
433
|
[files, dirs]
|
@@ -439,25 +453,7 @@ module Rails
|
|
439
453
|
end
|
440
454
|
|
441
455
|
attr_writer :config
|
442
|
-
|
443
|
-
def secrets
|
444
|
-
Rails.deprecator.warn(<<~MSG.squish)
|
445
|
-
`Rails.application.secrets` is deprecated in favor of `Rails.application.credentials` and will be removed in Rails 7.2.
|
446
|
-
MSG
|
447
|
-
@secrets ||= begin
|
448
|
-
secrets = ActiveSupport::OrderedOptions.new
|
449
|
-
files = config.paths["config/secrets"].existent
|
450
|
-
files = files.reject { |path| path.end_with?(".enc") } unless config.read_encrypted_secrets
|
451
|
-
secrets.merge! Rails::Secrets.parse(files, env: Rails.env)
|
452
|
-
|
453
|
-
# Fallback to config.secret_key_base if secrets.secret_key_base isn't set
|
454
|
-
secrets.secret_key_base ||= config.secret_key_base
|
455
|
-
|
456
|
-
secrets
|
457
|
-
end
|
458
|
-
end
|
459
|
-
|
460
|
-
attr_writer :secrets, :credentials
|
456
|
+
attr_writer :credentials
|
461
457
|
|
462
458
|
# The secret_key_base is used as the input secret to the application's key generator, which in turn
|
463
459
|
# is used to create all ActiveSupport::MessageVerifier and ActiveSupport::MessageEncryptor instances,
|
@@ -473,30 +469,10 @@ module Rails
|
|
473
469
|
# Dockerfile example: <tt>RUN SECRET_KEY_BASE_DUMMY=1 bundle exec rails assets:precompile</tt>.
|
474
470
|
#
|
475
471
|
# In all other environments, we look for it first in <tt>ENV["SECRET_KEY_BASE"]</tt>,
|
476
|
-
# then +credentials.secret_key_base
|
477
|
-
#
|
472
|
+
# then +credentials.secret_key_base+. For most applications, the correct place to store it is in the
|
473
|
+
# encrypted credentials file.
|
478
474
|
def secret_key_base
|
479
|
-
|
480
|
-
config.secret_key_base ||= generate_local_secret
|
481
|
-
else
|
482
|
-
validate_secret_key_base(
|
483
|
-
ENV["SECRET_KEY_BASE"] || credentials.secret_key_base || begin
|
484
|
-
secret_skb = secrets_secret_key_base
|
485
|
-
|
486
|
-
if secret_skb.equal?(config.secret_key_base)
|
487
|
-
config.secret_key_base
|
488
|
-
else
|
489
|
-
Rails.deprecator.warn(<<~MSG.squish)
|
490
|
-
Your `secret_key_base` is configured in `Rails.application.secrets`,
|
491
|
-
which is deprecated in favor of `Rails.application.credentials` and
|
492
|
-
will be removed in Rails 7.2.
|
493
|
-
MSG
|
494
|
-
|
495
|
-
secret_skb
|
496
|
-
end
|
497
|
-
end
|
498
|
-
)
|
499
|
-
end
|
475
|
+
config.secret_key_base
|
500
476
|
end
|
501
477
|
|
502
478
|
# Returns an ActiveSupport::EncryptedConfiguration instance for the
|
@@ -649,47 +625,12 @@ module Rails
|
|
649
625
|
default_stack.build_stack
|
650
626
|
end
|
651
627
|
|
652
|
-
def validate_secret_key_base(secret_key_base)
|
653
|
-
if secret_key_base.is_a?(String) && secret_key_base.present?
|
654
|
-
secret_key_base
|
655
|
-
elsif secret_key_base
|
656
|
-
raise ArgumentError, "`secret_key_base` for #{Rails.env} environment must be a type of String`"
|
657
|
-
else
|
658
|
-
raise ArgumentError, "Missing `secret_key_base` for '#{Rails.env}' environment, set this string with `bin/rails credentials:edit`"
|
659
|
-
end
|
660
|
-
end
|
661
|
-
|
662
628
|
def ensure_generator_templates_added
|
663
629
|
configured_paths = config.generators.templates
|
664
630
|
configured_paths.unshift(*(paths["lib/templates"].existent - configured_paths))
|
665
631
|
end
|
666
632
|
|
667
633
|
private
|
668
|
-
def generate_local_secret
|
669
|
-
if config.secret_key_base.nil?
|
670
|
-
key_file = Rails.root.join("tmp/local_secret.txt")
|
671
|
-
|
672
|
-
if File.exist?(key_file)
|
673
|
-
config.secret_key_base = File.binread(key_file)
|
674
|
-
elsif secrets_secret_key_base
|
675
|
-
config.secret_key_base = secrets_secret_key_base
|
676
|
-
else
|
677
|
-
random_key = SecureRandom.hex(64)
|
678
|
-
FileUtils.mkdir_p(key_file.dirname)
|
679
|
-
File.binwrite(key_file, random_key)
|
680
|
-
config.secret_key_base = File.binread(key_file)
|
681
|
-
end
|
682
|
-
end
|
683
|
-
|
684
|
-
config.secret_key_base
|
685
|
-
end
|
686
|
-
|
687
|
-
def secrets_secret_key_base
|
688
|
-
Rails.deprecator.silence do
|
689
|
-
secrets.secret_key_base
|
690
|
-
end
|
691
|
-
end
|
692
|
-
|
693
634
|
def build_request(env)
|
694
635
|
req = super
|
695
636
|
env["ORIGINAL_FULLPATH"] = req.fullpath
|