railties 6.1.7.9 → 7.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +89 -468
- data/MIT-LICENSE +1 -1
- data/RDOC_MAIN.rdoc +16 -16
- data/README.rdoc +0 -1
- data/lib/rails/app_updater.rb +2 -4
- data/lib/rails/application/bootstrap.rb +17 -5
- data/lib/rails/application/configuration.rb +52 -31
- data/lib/rails/application/default_middleware_stack.rb +6 -3
- data/lib/rails/application/finisher.rb +43 -85
- data/lib/rails/application/routes_reloader.rb +8 -0
- data/lib/rails/application.rb +24 -50
- data/lib/rails/application_controller.rb +2 -2
- data/lib/rails/autoloaders/inflector.rb +21 -0
- data/lib/rails/autoloaders.rb +12 -16
- data/lib/rails/code_statistics.rb +2 -2
- data/lib/rails/code_statistics_calculator.rb +10 -1
- data/lib/rails/command/base.rb +26 -12
- data/lib/rails/command/behavior.rb +1 -1
- data/lib/rails/command/environment_argument.rb +1 -1
- data/lib/rails/command.rb +8 -5
- data/lib/rails/commands/credentials/USAGE +4 -2
- data/lib/rails/commands/credentials/credentials_command/diffing.rb +26 -16
- data/lib/rails/commands/credentials/credentials_command.rb +6 -2
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +16 -15
- data/lib/rails/commands/help/USAGE +3 -2
- data/lib/rails/commands/runner/runner_command.rb +3 -2
- data/lib/rails/commands/server/server_command.rb +2 -5
- data/lib/rails/configuration.rb +18 -23
- data/lib/rails/engine/configuration.rb +2 -2
- data/lib/rails/engine.rb +23 -27
- data/lib/rails/gem_version.rb +4 -4
- data/lib/rails/generators/actions/create_migration.rb +2 -4
- data/lib/rails/generators/actions.rb +35 -13
- data/lib/rails/generators/app_base.rb +66 -102
- data/lib/rails/generators/app_name.rb +1 -1
- data/lib/rails/generators/base.rb +9 -13
- data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +2 -0
- data/lib/rails/generators/erb/scaffold/templates/edit.html.erb.tt +8 -4
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +5 -27
- data/lib/rails/generators/erb/scaffold/templates/new.html.erb.tt +7 -3
- data/lib/rails/generators/erb/scaffold/templates/partial.html.erb.tt +20 -0
- data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +7 -16
- data/lib/rails/generators/erb.rb +1 -1
- data/lib/rails/generators/generated_attribute.rb +40 -4
- data/lib/rails/generators/migration.rb +2 -6
- data/lib/rails/generators/model_helpers.rb +1 -1
- data/lib/rails/generators/named_base.rb +1 -1
- data/lib/rails/generators/rails/app/app_generator.rb +44 -88
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +41 -52
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css.tt +2 -2
- data/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/app/models/application_record.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +3 -10
- data/lib/rails/generators/rails/app/templates/bin/rails.tt +1 -4
- data/lib/rails/generators/rails/app/templates/bin/rake.tt +0 -3
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +9 -14
- data/lib/rails/generators/rails/app/templates/config/boot.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +5 -5
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +2 -11
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +9 -15
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +2 -7
- data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +1 -5
- data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +0 -5
- data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/initializers/inflections.rb.tt +4 -4
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_0.rb.tt +85 -0
- data/lib/rails/generators/rails/app/templates/config/locales/en.yml +3 -3
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +3 -0
- data/lib/rails/generators/rails/app/templates/config/storage.yml.tt +5 -5
- data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/gitattributes.tt +0 -5
- data/lib/rails/generators/rails/app/templates/gitignore.tt +0 -1
- data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +1 -1
- data/lib/rails/generators/rails/controller/controller_generator.rb +1 -2
- data/lib/rails/generators/rails/controller/templates/controller.rb.tt +0 -4
- data/lib/rails/generators/rails/db/system/change/change_generator.rb +1 -1
- data/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +40 -15
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +4 -2
- data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +9 -9
- data/lib/rails/generators/rails/plugin/templates/README.md.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +2 -2
- data/lib/rails/generators/rails/plugin/templates/app/models/%namespaced_name%/application_record.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +0 -3
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +4 -4
- data/lib/rails/generators/rails/plugin/templates/gitignore.tt +0 -5
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb.tt +2 -2
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/rails/boot.rb.tt +2 -2
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +3 -3
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +0 -19
- data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +1 -5
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +6 -10
- data/lib/rails/generators/resource_helpers.rb +2 -2
- data/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +2 -2
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +3 -3
- data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +5 -5
- 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 +3 -3
- data/lib/rails/generators/testing/behaviour.rb +1 -2
- data/lib/rails/generators.rb +9 -22
- data/lib/rails/info.rb +1 -1
- data/lib/rails/info_controller.rb +1 -3
- data/lib/rails/initializable.rb +1 -1
- data/lib/rails/mailers_controller.rb +2 -4
- data/lib/rails/rack/logger.rb +0 -1
- data/lib/rails/railtie/configuration.rb +1 -2
- data/lib/rails/railtie.rb +9 -9
- data/lib/rails/ruby_version_check.rb +3 -3
- data/lib/rails/secrets.rb +8 -10
- data/lib/rails/tasks/framework.rake +2 -8
- data/lib/rails/tasks/statistics.rake +3 -1
- data/lib/rails/tasks/tmp.rake +8 -1
- data/lib/rails/tasks/yarn.rake +5 -1
- data/lib/rails/tasks/zeitwerk.rake +2 -10
- data/lib/rails/templates/layouts/application.html.erb +15 -0
- data/lib/rails/templates/rails/mailers/email.html.erb +12 -10
- data/lib/rails/templates/rails/welcome/index.html.erb +3 -0
- data/lib/rails/test_unit/railtie.rb +0 -4
- data/lib/rails/test_unit/runner.rb +7 -5
- data/lib/rails/test_unit/testing.rake +4 -9
- data/lib/rails.rb +1 -0
- metadata +34 -36
- data/lib/rails/command/spellchecker.rb +0 -57
- data/lib/rails/generators/css/assets/assets_generator.rb +0 -15
- data/lib/rails/generators/css/assets/templates/stylesheet.css +0 -4
- data/lib/rails/generators/css/scaffold/scaffold_generator.rb +0 -18
- data/lib/rails/generators/rails/app/templates/app/javascript/channels/consumer.js +0 -6
- data/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js +0 -5
- data/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt +0 -23
- data/lib/rails/generators/rails/app/templates/bin/spring.tt +0 -13
- data/lib/rails/generators/rails/app/templates/bin/yarn.tt +0 -16
- data/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb.tt +0 -8
- data/lib/rails/generators/rails/app/templates/config/initializers/cookies_serializer.rb.tt +0 -5
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_1.rb.tt +0 -67
- data/lib/rails/generators/rails/app/templates/config/spring.rb.tt +0 -6
- data/lib/rails/generators/rails/app/templates/package.json.tt +0 -11
- data/lib/rails/generators/rails/assets/USAGE +0 -16
- data/lib/rails/generators/rails/assets/assets_generator.rb +0 -26
- data/lib/rails/generators/rails/assets/templates/stylesheet.css +0 -4
- data/lib/rails/generators/rails/scaffold/templates/scaffold.css +0 -80
data/RDOC_MAIN.rdoc
CHANGED
@@ -15,21 +15,21 @@ application into three layers: Model, View, and Controller, each with a specific
|
|
15
15
|
The <em><b>Model layer</b></em> represents the domain model (such as Account, Product,
|
16
16
|
Person, Post, etc.) and encapsulates the business logic specific to
|
17
17
|
your application. In \Rails, database-backed model classes are derived from
|
18
|
-
<tt>ActiveRecord::Base</tt>. {Active Record}[link
|
18
|
+
<tt>ActiveRecord::Base</tt>. {Active Record}[link:/files/activerecord/README_rdoc.html] allows you to present the data from
|
19
19
|
database rows as objects and embellish these data objects with business logic
|
20
20
|
methods. Although most \Rails models are backed by a database, models can also be ordinary
|
21
21
|
Ruby classes, or Ruby classes that implement a set of interfaces as provided by
|
22
|
-
the {Active Model}[link
|
22
|
+
the {Active Model}[link:/files/activemodel/README_rdoc.html] module.
|
23
23
|
|
24
24
|
== Controller layer
|
25
25
|
|
26
26
|
The <em><b>Controller layer</b></em> is responsible for handling incoming HTTP requests and
|
27
|
-
providing a suitable response. Usually this means returning \HTML, but \Rails controllers
|
27
|
+
providing a suitable response. Usually, this means returning \HTML, but \Rails controllers
|
28
28
|
can also generate XML, JSON, PDFs, mobile-specific views, and more. Controllers load and
|
29
|
-
manipulate models
|
29
|
+
manipulate models and render view templates in order to generate the appropriate HTTP response.
|
30
30
|
In \Rails, incoming requests are routed by Action Dispatch to an appropriate controller, and
|
31
31
|
controller classes are derived from <tt>ActionController::Base</tt>. Action Dispatch and Action Controller
|
32
|
-
are bundled together in {Action Pack}[link
|
32
|
+
are bundled together in {Action Pack}[link:/files/actionpack/README_rdoc.html].
|
33
33
|
|
34
34
|
== View layer
|
35
35
|
|
@@ -37,19 +37,19 @@ The <em><b>View layer</b></em> is composed of "templates" that are responsible f
|
|
37
37
|
appropriate representations of your application's resources. Templates can
|
38
38
|
come in a variety of formats, but most view templates are \HTML with embedded
|
39
39
|
Ruby code (ERB files). Views are typically rendered to generate a controller response,
|
40
|
-
or to generate the body of an email. In \Rails, View generation is handled by {Action View}[link
|
40
|
+
or to generate the body of an email. In \Rails, View generation is handled by {Action View}[link:/files/actionview/README_rdoc.html].
|
41
41
|
|
42
42
|
== Frameworks and libraries
|
43
43
|
|
44
|
-
{Active Record}[link
|
45
|
-
{Action Pack}[link
|
46
|
-
In addition to that, \Rails also comes with {Action Mailer}[link
|
47
|
-
to generate and send emails; {Action Mailbox}[link
|
48
|
-
{Active Job}[link
|
49
|
-
backends; {Action Cable}[link
|
50
|
-
integrate WebSockets with a \Rails application; {Active Storage}[link
|
51
|
-
a library to attach cloud and local files to \Rails applications; {Action Text}[link
|
52
|
-
and {Active Support}[link
|
44
|
+
{Active Record}[link:/files/activerecord/README_rdoc.html], {Active Model}[link:/files/activemodel/README_rdoc.html],
|
45
|
+
{Action Pack}[link:/files/actionpack/README_rdoc.html], and {Action View}[link:/files/actionview/README_rdoc.html] can each be used independently outside \Rails.
|
46
|
+
In addition to that, \Rails also comes with {Action Mailer}[link:/files/actionmailer/README_rdoc.html], a library
|
47
|
+
to generate and send emails; {Action Mailbox}[link:/files/actionmailbox/README_md.html], a library to receive emails within a Rails application;
|
48
|
+
{Active Job}[link:/files/activejob/README_md.html], a framework for declaring jobs and making them run on a variety of queueing
|
49
|
+
backends; {Action Cable}[link:/files/actioncable/README_md.html], a framework to
|
50
|
+
integrate WebSockets with a \Rails application; {Active Storage}[link:/files/activestorage/README_md.html],
|
51
|
+
a library to attach cloud and local files to \Rails applications; {Action Text}[link:/files/actiontext/README_md.html], a library to handle rich text content;
|
52
|
+
and {Active Support}[link:/files/activesupport/README_rdoc.html], a collection
|
53
53
|
of utility classes and standard library extensions that are useful for \Rails,
|
54
54
|
and may also be used independently outside \Rails.
|
55
55
|
|
@@ -72,7 +72,7 @@ and may also be used independently outside \Rails.
|
|
72
72
|
|
73
73
|
Run with <tt>--help</tt> or <tt>-h</tt> for options.
|
74
74
|
|
75
|
-
4. Go to <tt>http://localhost:3000</tt
|
75
|
+
4. Go to <tt>http://localhost:3000</tt>, and you'll see: "Yay! You’re on \Rails!"
|
76
76
|
|
77
77
|
5. Follow the guidelines to start developing your application. You may find the following resources handy:
|
78
78
|
|
data/README.rdoc
CHANGED
data/lib/rails/app_updater.rb
CHANGED
@@ -13,7 +13,7 @@ module Rails
|
|
13
13
|
def app_generator
|
14
14
|
@app_generator ||= begin
|
15
15
|
gen = Rails::Generators::AppGenerator.new ["rails"], generator_options, destination_root: Rails.root
|
16
|
-
File.exist?(Rails.root.join("config", "application.rb"))
|
16
|
+
gen.send(:valid_const?) unless File.exist?(Rails.root.join("config", "application.rb"))
|
17
17
|
gen
|
18
18
|
end
|
19
19
|
end
|
@@ -21,15 +21,13 @@ module Rails
|
|
21
21
|
private
|
22
22
|
def generator_options
|
23
23
|
options = { api: !!Rails.application.config.api_only, update: true }
|
24
|
-
options[:skip_javascript] = !File.exist?(Rails.root.join("bin", "yarn"))
|
25
24
|
options[:skip_active_record] = !defined?(ActiveRecord::Railtie)
|
26
25
|
options[:skip_active_storage] = !defined?(ActiveStorage::Engine) || !defined?(ActiveRecord::Railtie)
|
27
26
|
options[:skip_action_mailer] = !defined?(ActionMailer::Railtie)
|
28
27
|
options[:skip_action_cable] = !defined?(ActionCable::Engine)
|
29
28
|
options[:skip_sprockets] = !defined?(Sprockets::Railtie)
|
30
|
-
options[:skip_puma] = !defined?(Puma)
|
31
29
|
options[:skip_bootsnap] = !defined?(Bootsnap)
|
32
|
-
options[:
|
30
|
+
options[:updating] = true
|
33
31
|
options
|
34
32
|
end
|
35
33
|
end
|
@@ -44,7 +44,7 @@ module Rails
|
|
44
44
|
logger.level = ActiveSupport::Logger::WARN
|
45
45
|
logger.warn(
|
46
46
|
"Rails Error: Unable to access log file. Please ensure that #{path} exists and is writable " \
|
47
|
-
"(
|
47
|
+
"(i.e. make it writable for user and group: chmod 0664 #{path}). " \
|
48
48
|
"The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."
|
49
49
|
)
|
50
50
|
logger
|
@@ -59,14 +59,26 @@ module Rails
|
|
59
59
|
Rails.cache = ActiveSupport::Cache.lookup_store(*config.cache_store)
|
60
60
|
|
61
61
|
if Rails.cache.respond_to?(:middleware)
|
62
|
-
config.middleware.
|
62
|
+
config.middleware.insert_after(ActionDispatch::Executor, Rails.cache.middleware)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
#
|
68
|
-
|
69
|
-
|
67
|
+
# We setup the once autoloader this early so that engines and applications
|
68
|
+
# are able to autoload from these paths during initialization.
|
69
|
+
initializer :setup_once_autoloader do
|
70
|
+
autoloader = Rails.autoloaders.once
|
71
|
+
|
72
|
+
ActiveSupport::Dependencies.autoload_once_paths.freeze
|
73
|
+
ActiveSupport::Dependencies.autoload_once_paths.uniq.each do |path|
|
74
|
+
# Zeitwerk only accepts existing directories in `push_dir`.
|
75
|
+
next unless File.directory?(path)
|
76
|
+
|
77
|
+
autoloader.push_dir(path)
|
78
|
+
autoloader.do_not_eager_load(path) unless ActiveSupport::Dependencies.eager_load?(path)
|
79
|
+
end
|
80
|
+
|
81
|
+
autoloader.setup
|
70
82
|
end
|
71
83
|
|
72
84
|
initializer :bootstrap_hook, group: :all do |app|
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require "ipaddr"
|
4
4
|
require "active_support/core_ext/kernel/reporting"
|
5
|
-
require "active_support/core_ext/symbol/starts_ends_with"
|
6
5
|
require "active_support/file_update_checker"
|
7
6
|
require "active_support/configuration_file"
|
8
7
|
require "rails/engine/configuration"
|
@@ -24,7 +23,7 @@ module Rails
|
|
24
23
|
:require_master_key, :credentials, :disable_sandbox, :add_autoload_paths_to_load_path,
|
25
24
|
:rake_eager_load
|
26
25
|
|
27
|
-
attr_reader :encoding, :api_only, :loaded_config_version
|
26
|
+
attr_reader :encoding, :api_only, :loaded_config_version
|
28
27
|
|
29
28
|
def initialize(*)
|
30
29
|
super
|
@@ -34,11 +33,8 @@ module Rails
|
|
34
33
|
@filter_parameters = []
|
35
34
|
@filter_redirect = []
|
36
35
|
@helpers_paths = []
|
37
|
-
if Rails.env.development?
|
38
|
-
|
39
|
-
else
|
40
|
-
@hosts = []
|
41
|
-
end
|
36
|
+
@hosts = Array(([".localhost", IPAddr.new("0.0.0.0/0"), IPAddr.new("::/0")] if Rails.env.development?))
|
37
|
+
@hosts.concat(ENV["RAILS_DEVELOPMENT_HOSTS"].to_s.split(",").map(&:strip)) if Rails.env.development?
|
42
38
|
@host_authorization = {}
|
43
39
|
@public_file_server = ActiveSupport::OrderedOptions.new
|
44
40
|
@public_file_server.enabled = true
|
@@ -74,7 +70,6 @@ module Rails
|
|
74
70
|
@credentials = ActiveSupport::OrderedOptions.new
|
75
71
|
@credentials.content_path = default_credentials_content_path
|
76
72
|
@credentials.key_path = default_credentials_key_path
|
77
|
-
@autoloader = :classic
|
78
73
|
@disable_sandbox = false
|
79
74
|
@add_autoload_paths_to_load_path = true
|
80
75
|
@permissions_policy = nil
|
@@ -120,7 +115,7 @@ module Rails
|
|
120
115
|
|
121
116
|
if respond_to?(:active_support)
|
122
117
|
active_support.use_authenticated_message_encryption = true
|
123
|
-
active_support.hash_digest_class = ::Digest::SHA1
|
118
|
+
active_support.hash_digest_class = OpenSSL::Digest::SHA1
|
124
119
|
end
|
125
120
|
|
126
121
|
if respond_to?(:action_controller)
|
@@ -133,8 +128,6 @@ module Rails
|
|
133
128
|
when "6.0"
|
134
129
|
load_defaults "5.2"
|
135
130
|
|
136
|
-
self.autoloader = :zeitwerk if RUBY_ENGINE == "ruby"
|
137
|
-
|
138
131
|
if respond_to?(:action_view)
|
139
132
|
action_view.default_enforce_utf8 = false
|
140
133
|
end
|
@@ -160,17 +153,11 @@ module Rails
|
|
160
153
|
when "6.1"
|
161
154
|
load_defaults "6.0"
|
162
155
|
|
163
|
-
self.autoloader = :zeitwerk if %w[ruby truffleruby].include?(RUBY_ENGINE)
|
164
|
-
|
165
156
|
if respond_to?(:active_record)
|
166
157
|
active_record.has_many_inversing = true
|
167
158
|
active_record.legacy_connection_handling = false
|
168
159
|
end
|
169
160
|
|
170
|
-
if respond_to?(:active_storage)
|
171
|
-
active_storage.track_variants = true
|
172
|
-
end
|
173
|
-
|
174
161
|
if respond_to?(:active_job)
|
175
162
|
active_job.retry_jitter = 0.15
|
176
163
|
active_job.skip_after_callbacks_if_terminated = true
|
@@ -191,6 +178,8 @@ module Rails
|
|
191
178
|
end
|
192
179
|
|
193
180
|
if respond_to?(:active_storage)
|
181
|
+
active_storage.track_variants = true
|
182
|
+
|
194
183
|
active_storage.queues.analysis = nil
|
195
184
|
active_storage.queues.purge = nil
|
196
185
|
end
|
@@ -205,6 +194,50 @@ module Rails
|
|
205
194
|
end
|
206
195
|
|
207
196
|
ActiveSupport.utc_to_local_returns_utc_offset_times = true
|
197
|
+
when "7.0"
|
198
|
+
load_defaults "6.1"
|
199
|
+
|
200
|
+
if respond_to?(:action_dispatch)
|
201
|
+
action_dispatch.return_only_request_media_type_on_content_type = false
|
202
|
+
action_dispatch.cookies_serializer = :json
|
203
|
+
end
|
204
|
+
|
205
|
+
if respond_to?(:action_controller)
|
206
|
+
action_controller.silence_disabled_session_errors = false
|
207
|
+
end
|
208
|
+
|
209
|
+
if respond_to?(:action_view)
|
210
|
+
action_view.button_to_generates_button_tag = true
|
211
|
+
action_view.apply_stylesheet_media_default = false
|
212
|
+
end
|
213
|
+
|
214
|
+
if respond_to?(:active_support)
|
215
|
+
active_support.hash_digest_class = OpenSSL::Digest::SHA256
|
216
|
+
active_support.key_generator_hash_digest_class = OpenSSL::Digest::SHA256
|
217
|
+
active_support.remove_deprecated_time_with_zone_name = true
|
218
|
+
active_support.cache_format_version = 7.0
|
219
|
+
end
|
220
|
+
|
221
|
+
if respond_to?(:action_mailer)
|
222
|
+
action_mailer.smtp_timeout = 5
|
223
|
+
end
|
224
|
+
|
225
|
+
if respond_to?(:active_storage)
|
226
|
+
active_storage.video_preview_arguments =
|
227
|
+
"-vf 'select=eq(n\\,0)+eq(key\\,1)+gt(scene\\,0.015),loop=loop=-1:size=2,trim=start_frame=1'" \
|
228
|
+
" -frames:v 1 -f image2"
|
229
|
+
|
230
|
+
active_storage.variant_processor = :vips
|
231
|
+
end
|
232
|
+
|
233
|
+
if respond_to?(:active_record)
|
234
|
+
active_record.verify_foreign_keys_for_fixtures = true
|
235
|
+
active_record.partial_inserts = false
|
236
|
+
end
|
237
|
+
|
238
|
+
if respond_to?(:action_controller)
|
239
|
+
action_controller.raise_on_open_redirects = true
|
240
|
+
end
|
208
241
|
else
|
209
242
|
raise "Unknown version #{target_version.to_s.inspect}"
|
210
243
|
end
|
@@ -335,7 +368,7 @@ module Rails
|
|
335
368
|
end
|
336
369
|
end
|
337
370
|
|
338
|
-
def session_store?
|
371
|
+
def session_store? # :nodoc:
|
339
372
|
@session_store
|
340
373
|
end
|
341
374
|
|
@@ -359,18 +392,6 @@ module Rails
|
|
359
392
|
end
|
360
393
|
end
|
361
394
|
|
362
|
-
def autoloader=(autoloader)
|
363
|
-
case autoloader
|
364
|
-
when :classic
|
365
|
-
@autoloader = autoloader
|
366
|
-
when :zeitwerk
|
367
|
-
require "zeitwerk"
|
368
|
-
@autoloader = autoloader
|
369
|
-
else
|
370
|
-
raise ArgumentError, "config.autoloader may be :classic or :zeitwerk, got #{autoloader.inspect} instead"
|
371
|
-
end
|
372
|
-
end
|
373
|
-
|
374
395
|
def default_log_file
|
375
396
|
path = paths["log"].first
|
376
397
|
unless File.exist? File.dirname path
|
@@ -383,7 +404,7 @@ module Rails
|
|
383
404
|
f
|
384
405
|
end
|
385
406
|
|
386
|
-
class Custom
|
407
|
+
class Custom # :nodoc:
|
387
408
|
def initialize
|
388
409
|
@configurations = Hash.new
|
389
410
|
end
|
@@ -42,7 +42,7 @@ module Rails
|
|
42
42
|
|
43
43
|
middleware.use ::ActionDispatch::Executor, app.executor
|
44
44
|
|
45
|
-
middleware.use ::
|
45
|
+
middleware.use ::ActionDispatch::MiddlewareStack::FakeRuntime
|
46
46
|
middleware.use ::Rack::MethodOverride unless config.api_only
|
47
47
|
middleware.use ::ActionDispatch::RequestId, header: config.action_dispatch.request_id_header
|
48
48
|
middleware.use ::ActionDispatch::RemoteIp, config.action_dispatch.ip_spoofing_check, config.action_dispatch.trusted_proxies
|
@@ -50,7 +50,10 @@ module Rails
|
|
50
50
|
middleware.use ::Rails::Rack::Logger, config.log_tags
|
51
51
|
middleware.use ::ActionDispatch::ShowExceptions, show_exceptions_app
|
52
52
|
middleware.use ::ActionDispatch::DebugExceptions, app, config.debug_exception_response_format
|
53
|
-
|
53
|
+
|
54
|
+
if config.consider_all_requests_local
|
55
|
+
middleware.use ::ActionDispatch::ActionableExceptions
|
56
|
+
end
|
54
57
|
|
55
58
|
unless config.cache_classes
|
56
59
|
middleware.use ::ActionDispatch::Reloader, app.reloader
|
@@ -64,10 +67,10 @@ module Rails
|
|
64
67
|
config.session_options[:secure] = true
|
65
68
|
end
|
66
69
|
middleware.use config.session_store, config.session_options
|
67
|
-
middleware.use ::ActionDispatch::Flash
|
68
70
|
end
|
69
71
|
|
70
72
|
unless config.api_only
|
73
|
+
middleware.use ::ActionDispatch::Flash
|
71
74
|
middleware.use ::ActionDispatch::ContentSecurityPolicy::Middleware
|
72
75
|
middleware.use ::ActionDispatch::PermissionsPolicy::Middleware
|
73
76
|
end
|
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "zeitwerk"
|
3
4
|
require "active_support/core_ext/string/inflections"
|
4
5
|
require "active_support/core_ext/array/conversions"
|
6
|
+
require "active_support/descendants_tracker"
|
7
|
+
require "active_support/dependencies"
|
5
8
|
|
6
9
|
module Rails
|
7
10
|
class Application
|
@@ -12,88 +15,34 @@ module Rails
|
|
12
15
|
config.generators.templates.unshift(*paths["lib/templates"].existent)
|
13
16
|
end
|
14
17
|
|
15
|
-
initializer :
|
16
|
-
|
17
|
-
ActiveSupport::Dependencies.autoload_paths
|
18
|
+
initializer :setup_main_autoloader do
|
19
|
+
autoloader = Rails.autoloaders.main
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end_error
|
24
|
-
end
|
25
|
-
end
|
21
|
+
ActiveSupport::Dependencies.autoload_paths.freeze
|
22
|
+
ActiveSupport::Dependencies.autoload_paths.uniq.each do |path|
|
23
|
+
# Zeitwerk only accepts existing directories in `push_dir`.
|
24
|
+
next unless File.directory?(path)
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
# constants just won't be found, raising regular NameError exceptions.
|
30
|
-
initializer :warn_if_autoloaded, before: :let_zeitwerk_take_over do
|
31
|
-
next if config.cache_classes
|
32
|
-
next if ActiveSupport::Dependencies.autoloaded_constants.empty?
|
33
|
-
|
34
|
-
autoloaded = ActiveSupport::Dependencies.autoloaded_constants
|
35
|
-
constants = "constant".pluralize(autoloaded.size)
|
36
|
-
enum = autoloaded.to_sentence
|
37
|
-
have = autoloaded.size == 1 ? "has" : "have"
|
38
|
-
these = autoloaded.size == 1 ? "This" : "These"
|
39
|
-
example = autoloaded.first
|
40
|
-
example_klass = example.constantize.class
|
41
|
-
|
42
|
-
if config.autoloader == :zeitwerk
|
43
|
-
ActiveSupport::DescendantsTracker.clear
|
44
|
-
ActiveSupport::Dependencies.clear
|
45
|
-
|
46
|
-
unload_message = "#{these} autoloaded #{constants} #{have} been unloaded."
|
47
|
-
else
|
48
|
-
unload_message = "`config.autoloader` is set to `#{config.autoloader}`. #{these} autoloaded #{constants} would have been unloaded if `config.autoloader` had been set to `:zeitwerk`."
|
26
|
+
autoloader.push_dir(path)
|
27
|
+
autoloader.do_not_eager_load(path) unless ActiveSupport::Dependencies.eager_load?(path)
|
49
28
|
end
|
50
29
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
Being able to do this is deprecated. Autoloading during initialization is going
|
55
|
-
to be an error condition in future versions of Rails.
|
56
|
-
|
57
|
-
Reloading does not reboot the application, and therefore code executed during
|
58
|
-
initialization does not run again. So, if you reload #{example}, for example,
|
59
|
-
the expected changes won't be reflected in that stale #{example_klass} object.
|
60
|
-
|
61
|
-
#{unload_message}
|
62
|
-
|
63
|
-
In order to autoload safely at boot time, please wrap your code in a reloader
|
64
|
-
callback this way:
|
30
|
+
unless config.cache_classes
|
31
|
+
autoloader.enable_reloading
|
32
|
+
ActiveSupport::Dependencies.autoloader = autoloader
|
65
33
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
That block runs when the application boots, and every time there is a reload.
|
71
|
-
For historical reasons, it may run twice, so it has to be idempotent.
|
72
|
-
|
73
|
-
Check the "Autoloading and Reloading Constants" guide to learn more about how
|
74
|
-
Rails autoloads and reloads.
|
75
|
-
WARNING
|
76
|
-
end
|
77
|
-
|
78
|
-
initializer :let_zeitwerk_take_over do
|
79
|
-
if config.autoloader == :zeitwerk
|
80
|
-
require "active_support/dependencies/zeitwerk_integration"
|
81
|
-
ActiveSupport::Dependencies::ZeitwerkIntegration.take_over(enable_reloading: !config.cache_classes)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
initializer :add_builtin_route do |app|
|
86
|
-
if Rails.env.development?
|
87
|
-
app.routes.prepend do
|
88
|
-
get "/rails/info/properties" => "rails/info#properties", internal: true
|
89
|
-
get "/rails/info/routes" => "rails/info#routes", internal: true
|
90
|
-
get "/rails/info" => "rails/info#index", internal: true
|
34
|
+
autoloader.on_load do |_cpath, value, _abspath|
|
35
|
+
if value.is_a?(Class) && value.singleton_class < ActiveSupport::DescendantsTracker
|
36
|
+
ActiveSupport::Dependencies._autoloaded_tracked_classes << value
|
37
|
+
end
|
91
38
|
end
|
92
39
|
|
93
|
-
|
94
|
-
|
40
|
+
autoloader.on_unload do |_cpath, value, _abspath|
|
41
|
+
value.before_remove_const if value.respond_to?(:before_remove_const)
|
95
42
|
end
|
96
43
|
end
|
44
|
+
|
45
|
+
autoloader.setup
|
97
46
|
end
|
98
47
|
|
99
48
|
# Setup default session store if not already set in config/application.rb
|
@@ -127,10 +76,7 @@ module Rails
|
|
127
76
|
initializer :eager_load! do
|
128
77
|
if config.eager_load
|
129
78
|
ActiveSupport.run_load_hooks(:before_eager_load, self)
|
130
|
-
|
131
|
-
# want to eager load any dependency managed by Zeitwerk regardless of
|
132
|
-
# the autoloading mode of the application.
|
133
|
-
Zeitwerk::Loader.eager_load_all if defined?(Zeitwerk)
|
79
|
+
Zeitwerk::Loader.eager_load_all
|
134
80
|
config.eager_load_namespaces.each(&:eager_load!)
|
135
81
|
end
|
136
82
|
end
|
@@ -187,6 +133,22 @@ module Rails
|
|
187
133
|
end
|
188
134
|
end
|
189
135
|
|
136
|
+
initializer :add_internal_routes do |app|
|
137
|
+
if Rails.env.development?
|
138
|
+
app.routes.prepend do
|
139
|
+
get "/rails/info/properties" => "rails/info#properties", internal: true
|
140
|
+
get "/rails/info/routes" => "rails/info#routes", internal: true
|
141
|
+
get "/rails/info" => "rails/info#index", internal: true
|
142
|
+
end
|
143
|
+
|
144
|
+
routes_reloader.run_after_load_paths = -> do
|
145
|
+
app.routes.append do
|
146
|
+
get "/" => "rails/welcome#index", internal: true
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
190
152
|
# Set routes reload after the finisher hook to ensure routes added in
|
191
153
|
# the hook are taken into account.
|
192
154
|
initializer :set_routes_reloader_hook do |app|
|
@@ -213,7 +175,10 @@ module Rails
|
|
213
175
|
# added in the hook are taken into account.
|
214
176
|
initializer :set_clear_dependencies_hook, group: :all do |app|
|
215
177
|
callback = lambda do
|
216
|
-
|
178
|
+
# Order matters.
|
179
|
+
ActiveSupport::DescendantsTracker.clear(
|
180
|
+
only: ActiveSupport::Dependencies._autoloaded_tracked_classes
|
181
|
+
)
|
217
182
|
ActiveSupport::Dependencies.clear
|
218
183
|
end
|
219
184
|
|
@@ -251,13 +216,6 @@ module Rails
|
|
251
216
|
end
|
252
217
|
end
|
253
218
|
end
|
254
|
-
|
255
|
-
# Disable dependency loading during request cycle
|
256
|
-
initializer :disable_dependency_loading do
|
257
|
-
if config.eager_load && config.cache_classes && !config.enable_dependency_loading
|
258
|
-
ActiveSupport::Dependencies.unhook!
|
259
|
-
end
|
260
|
-
end
|
261
219
|
end
|
262
220
|
end
|
263
221
|
end
|
@@ -5,8 +5,11 @@ require "active_support/core_ext/module/delegation"
|
|
5
5
|
module Rails
|
6
6
|
class Application
|
7
7
|
class RoutesReloader
|
8
|
+
include ActiveSupport::Callbacks
|
9
|
+
|
8
10
|
attr_reader :route_sets, :paths, :external_routes
|
9
11
|
attr_accessor :eager_load
|
12
|
+
attr_writer :run_after_load_paths # :nodoc:
|
10
13
|
delegate :execute_if_updated, :execute, :updated?, to: :updater
|
11
14
|
|
12
15
|
def initialize
|
@@ -45,6 +48,11 @@ module Rails
|
|
45
48
|
|
46
49
|
def load_paths
|
47
50
|
paths.each { |path| load(path) }
|
51
|
+
run_after_load_paths.call
|
52
|
+
end
|
53
|
+
|
54
|
+
def run_after_load_paths
|
55
|
+
@run_after_load_paths ||= -> { }
|
48
56
|
end
|
49
57
|
|
50
58
|
def finalize!
|