railties 5.2.4 → 6.0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +317 -130
- data/MIT-LICENSE +1 -1
- data/RDOC_MAIN.rdoc +38 -32
- data/README.rdoc +2 -2
- data/lib/minitest/rails_plugin.rb +7 -11
- data/lib/rails.rb +5 -0
- data/lib/rails/all.rb +4 -0
- data/lib/rails/api/generator.rb +2 -1
- data/lib/rails/api/task.rb +17 -0
- data/lib/rails/app_loader.rb +2 -2
- data/lib/rails/app_updater.rb +3 -1
- data/lib/rails/application.rb +72 -30
- data/lib/rails/application/bootstrap.rb +2 -10
- data/lib/rails/application/configuration.rb +114 -13
- data/lib/rails/application/default_middleware_stack.rb +3 -0
- data/lib/rails/application/dummy_erb_compiler.rb +18 -0
- data/lib/rails/application/finisher.rb +54 -0
- data/lib/rails/autoloaders.rb +48 -0
- data/lib/rails/backtrace_cleaner.rb +5 -17
- data/lib/rails/code_statistics.rb +3 -3
- data/lib/rails/command.rb +11 -10
- data/lib/rails/command/base.rb +12 -4
- data/lib/rails/command/behavior.rb +7 -48
- data/lib/rails/command/environment_argument.rb +8 -15
- data/lib/rails/command/spellchecker.rb +58 -0
- data/lib/rails/commands/console/console_command.rb +6 -0
- data/lib/rails/commands/credentials/USAGE +19 -1
- data/lib/rails/commands/credentials/credentials_command.rb +52 -19
- data/lib/rails/commands/db/system/change/change_command.rb +20 -0
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +20 -8
- data/lib/rails/commands/dev/dev_command.rb +19 -0
- data/lib/rails/commands/encrypted/USAGE +1 -1
- data/lib/rails/commands/encrypted/encrypted_command.rb +2 -2
- data/lib/rails/commands/help/help_command.rb +1 -1
- data/lib/rails/commands/initializers/initializers_command.rb +23 -0
- data/lib/rails/commands/new/new_command.rb +2 -2
- data/lib/rails/commands/notes/notes_command.rb +39 -0
- data/lib/rails/commands/plugin/plugin_command.rb +1 -1
- data/lib/rails/commands/routes/routes_command.rb +37 -0
- data/lib/rails/commands/runner/runner_command.rb +13 -9
- data/lib/rails/commands/secrets/USAGE +3 -3
- data/lib/rails/commands/secrets/secrets_command.rb +3 -3
- data/lib/rails/commands/server/server_command.rb +113 -50
- data/lib/rails/configuration.rb +1 -7
- data/lib/rails/engine.rb +24 -16
- data/lib/rails/engine/configuration.rb +5 -2
- data/lib/rails/gem_version.rb +4 -4
- data/lib/rails/generators.rb +11 -10
- data/lib/rails/generators/actions.rb +52 -39
- data/lib/rails/generators/app_base.rb +53 -93
- data/lib/rails/generators/app_name.rb +50 -0
- data/lib/rails/generators/database.rb +58 -0
- data/lib/rails/generators/erb/mailer/mailer_generator.rb +1 -1
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +6 -3
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +1 -1
- data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +9 -1
- data/lib/rails/generators/generated_attribute.rb +53 -27
- data/lib/rails/generators/migration.rb +1 -2
- data/lib/rails/generators/model_helpers.rb +8 -1
- data/lib/rails/generators/named_base.rb +2 -6
- data/lib/rails/generators/rails/app/app_generator.rb +37 -71
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +7 -10
- data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +0 -3
- data/lib/rails/generators/rails/app/templates/app/{assets/javascripts/cable.js.tt → javascript/channels/consumer.js} +2 -9
- data/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js +5 -0
- data/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt +23 -0
- data/lib/rails/generators/rails/app/templates/app/jobs/application_job.rb.tt +5 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +4 -4
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +7 -7
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +2 -0
- data/lib/rails/generators/rails/app/templates/config/cable.yml.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml.tt +2 -2
- 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 +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +4 -4
- 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 +6 -6
- 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 +2 -2
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +5 -2
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +28 -12
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +13 -6
- data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +7 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_0.rb.tt +45 -0
- data/lib/rails/generators/rails/app/templates/config/locales/en.yml +1 -1
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +4 -3
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/spring.rb.tt +6 -6
- data/lib/rails/generators/rails/app/templates/gitignore.tt +3 -7
- data/lib/rails/generators/rails/app/templates/package.json.tt +7 -1
- data/lib/rails/generators/rails/app/templates/public/robots.txt +1 -1
- data/lib/rails/generators/rails/app/templates/ruby-version.tt +1 -1
- data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +11 -0
- data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +7 -0
- data/lib/rails/generators/rails/assets/USAGE +1 -4
- data/lib/rails/generators/rails/assets/assets_generator.rb +0 -1
- data/lib/rails/generators/rails/controller/controller_generator.rb +11 -1
- data/lib/rails/generators/rails/credentials/credentials_generator.rb +7 -8
- data/lib/rails/generators/rails/db/system/change/change_generator.rb +65 -0
- data/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb +4 -5
- data/lib/rails/generators/rails/helper/helper_generator.rb +5 -0
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +9 -33
- data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/jobs/%namespaced_name%/application_job.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/models/%namespaced_name%/application_record.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/gitignore.tt +2 -1
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/railtie.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +1 -2
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +14 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +1 -1
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +1 -1
- data/lib/rails/generators/resource_helpers.rb +1 -6
- data/lib/rails/generators/test_unit/integration/integration_generator.rb +6 -0
- data/lib/rails/generators/test_unit/job/job_generator.rb +5 -0
- data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +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 +8 -3
- data/lib/rails/generators/test_unit/system/system_generator.rb +5 -0
- data/lib/rails/generators/testing/behaviour.rb +3 -0
- data/lib/rails/info.rb +3 -3
- data/lib/rails/info_controller.rb +1 -1
- data/lib/rails/mailers_controller.rb +7 -4
- data/lib/rails/paths.rb +19 -9
- data/lib/rails/railtie.rb +1 -1
- data/lib/rails/ruby_version_check.rb +3 -3
- data/lib/rails/secrets.rb +0 -1
- data/lib/rails/source_annotation_extractor.rb +138 -117
- data/lib/rails/tasks.rb +1 -0
- data/lib/rails/tasks/annotations.rake +9 -9
- data/lib/rails/tasks/dev.rake +5 -4
- data/lib/rails/tasks/framework.rake +5 -1
- data/lib/rails/tasks/initializers.rake +5 -4
- data/lib/rails/tasks/log.rake +0 -1
- data/lib/rails/tasks/routes.rake +4 -26
- data/lib/rails/tasks/statistics.rake +4 -0
- data/lib/rails/tasks/yarn.rake +1 -1
- data/lib/rails/tasks/zeitwerk.rake +66 -0
- data/lib/rails/templates/rails/welcome/index.html.erb +2 -2
- data/lib/rails/test_help.rb +11 -9
- data/lib/rails/test_unit/reporter.rb +1 -1
- data/lib/rails/test_unit/runner.rb +5 -5
- data/lib/rails/test_unit/testing.rake +1 -1
- metadata +34 -22
- data/lib/rails/generators/js/assets/assets_generator.rb +0 -15
- data/lib/rails/generators/js/assets/templates/javascript.js +0 -2
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +0 -22
- data/lib/rails/generators/rails/app/templates/bin/bundle.tt +0 -2
- data/lib/rails/generators/rails/app/templates/bin/update.tt +0 -34
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_2.rb.tt +0 -38
- data/lib/rails/generators/rails/assets/templates/javascript.js +0 -2
data/MIT-LICENSE
CHANGED
data/RDOC_MAIN.rdoc
CHANGED
|
@@ -1,48 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
= Welcome to \Rails
|
|
2
|
+
|
|
3
|
+
== What's \Rails
|
|
2
4
|
|
|
3
5
|
\Rails is a web-application framework that includes everything needed to
|
|
4
6
|
create database-backed web applications according to the
|
|
5
|
-
{Model-View-Controller (MVC)}[
|
|
7
|
+
{Model-View-Controller (MVC)}[https://en.wikipedia.org/wiki/Model-view-controller]
|
|
6
8
|
pattern.
|
|
7
9
|
|
|
8
10
|
Understanding the MVC pattern is key to understanding \Rails. MVC divides your
|
|
9
|
-
application into three layers, each with a specific responsibility.
|
|
11
|
+
application into three layers: Model, View, and Controller, each with a specific responsibility.
|
|
12
|
+
|
|
13
|
+
== Model layer
|
|
10
14
|
|
|
11
|
-
The <em>Model layer</em> represents
|
|
12
|
-
Person, Post, etc.) and encapsulates the business logic
|
|
15
|
+
The <em><b>Model layer</b></em> represents the domain model (such as Account, Product,
|
|
16
|
+
Person, Post, etc.) and encapsulates the business logic specific to
|
|
13
17
|
your application. In \Rails, database-backed model classes are derived from
|
|
14
|
-
ActiveRecord::Base
|
|
18
|
+
<tt>ActiveRecord::Base</tt>. {Active Record}[link:files/activerecord/README_rdoc.html] allows you to present the data from
|
|
15
19
|
database rows as objects and embellish these data objects with business logic
|
|
16
|
-
methods.
|
|
17
|
-
Although most \Rails models are backed by a database, models can also be ordinary
|
|
20
|
+
methods. Although most \Rails models are backed by a database, models can also be ordinary
|
|
18
21
|
Ruby classes, or Ruby classes that implement a set of interfaces as provided by
|
|
19
|
-
the Active Model
|
|
22
|
+
the {Active Model}[link:files/activemodel/README_rdoc.html] module.
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
== Controller layer
|
|
25
|
+
|
|
26
|
+
The <em><b>Controller layer</b></em> is responsible for handling incoming HTTP requests and
|
|
22
27
|
providing a suitable response. Usually this means returning \HTML, but \Rails controllers
|
|
23
28
|
can also generate XML, JSON, PDFs, mobile-specific views, and more. Controllers load and
|
|
24
29
|
manipulate models, and render view templates in order to generate the appropriate HTTP response.
|
|
25
30
|
In \Rails, incoming requests are routed by Action Dispatch to an appropriate controller, and
|
|
26
|
-
controller classes are derived from ActionController::Base
|
|
27
|
-
are bundled together in Action Pack.
|
|
28
|
-
|
|
31
|
+
controller classes are derived from <tt>ActionController::Base</tt>. Action Dispatch and Action Controller
|
|
32
|
+
are bundled together in {Action Pack}[link:files/actionpack/README_rdoc.html].
|
|
33
|
+
|
|
34
|
+
== View layer
|
|
29
35
|
|
|
30
|
-
The <em>View layer</em> is composed of "templates" that are responsible for providing
|
|
36
|
+
The <em><b>View layer</b></em> is composed of "templates" that are responsible for providing
|
|
31
37
|
appropriate representations of your application's resources. Templates can
|
|
32
38
|
come in a variety of formats, but most view templates are \HTML with embedded
|
|
33
39
|
Ruby code (ERB files). Views are typically rendered to generate a controller response,
|
|
34
|
-
or to generate the body of an email. In \Rails, View generation is handled by Action View.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
and
|
|
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
|
+
|
|
42
|
+
== Frameworks and libraries
|
|
43
|
+
|
|
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
|
|
46
53
|
of utility classes and standard library extensions that are useful for \Rails,
|
|
47
54
|
and may also be used independently outside \Rails.
|
|
48
55
|
|
|
@@ -70,18 +77,17 @@ and may also be used independently outside \Rails.
|
|
|
70
77
|
5. Follow the guidelines to start developing your application. You may find the following resources handy:
|
|
71
78
|
|
|
72
79
|
* The \README file created within your application.
|
|
73
|
-
* {Getting Started with \Rails}[
|
|
74
|
-
* {Ruby on \Rails Guides}[
|
|
75
|
-
* {The API Documentation}[
|
|
76
|
-
* {Ruby on \Rails Tutorial}[https://www.railstutorial.org/book].
|
|
80
|
+
* {Getting Started with \Rails}[https://guides.rubyonrails.org/getting_started.html].
|
|
81
|
+
* {Ruby on \Rails Guides}[https://guides.rubyonrails.org].
|
|
82
|
+
* {The API Documentation}[https://api.rubyonrails.org].
|
|
77
83
|
|
|
78
84
|
== Contributing
|
|
79
85
|
|
|
80
86
|
We encourage you to contribute to Ruby on \Rails! Please check out the
|
|
81
|
-
{Contributing to Ruby on \Rails guide}[
|
|
87
|
+
{Contributing to Ruby on \Rails guide}[https://guides.rubyonrails.org/contributing_to_ruby_on_rails.html] for guidelines about how to proceed. {Join us!}[http://contributors.rubyonrails.org]
|
|
82
88
|
|
|
83
89
|
Trying to report a possible security vulnerability in \Rails? Please
|
|
84
|
-
check out our {security policy}[
|
|
90
|
+
check out our {security policy}[https://rubyonrails.org/security/] for
|
|
85
91
|
guidelines about how to proceed.
|
|
86
92
|
|
|
87
93
|
Everyone interacting in \Rails and its sub-projects' codebases, issue trackers, chat rooms, and mailing lists is expected to follow the \Rails {code of conduct}[http://rubyonrails.org/conduct/].
|
data/README.rdoc
CHANGED
|
@@ -17,7 +17,7 @@ The latest version of Railties can be installed with RubyGems:
|
|
|
17
17
|
|
|
18
18
|
Source code can be downloaded as part of the Rails project on GitHub
|
|
19
19
|
|
|
20
|
-
* https://github.com/rails/rails/tree/
|
|
20
|
+
* https://github.com/rails/rails/tree/master/railties
|
|
21
21
|
|
|
22
22
|
== License
|
|
23
23
|
|
|
@@ -29,7 +29,7 @@ Railties is released under the MIT license:
|
|
|
29
29
|
|
|
30
30
|
API documentation is at
|
|
31
31
|
|
|
32
|
-
*
|
|
32
|
+
* https://api.rubyonrails.org
|
|
33
33
|
|
|
34
34
|
Bug reports can be filed for the Ruby on Rails project here:
|
|
35
35
|
|
|
@@ -43,21 +43,17 @@ module Minitest
|
|
|
43
43
|
Minitest.backtrace_filter = ::Rails.backtrace_cleaner if ::Rails.respond_to?(:backtrace_cleaner)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return unless minitest_reporter.kind_of?(Minitest::CompositeReporter)
|
|
46
|
+
# Suppress summary reports when outputting inline rerun snippets.
|
|
47
|
+
if reporter.reporters.reject! { |reporter| reporter.kind_of?(SummaryReporter) }
|
|
48
|
+
reporter << SuppressedSummaryReporter.new(options[:io], options)
|
|
49
|
+
end
|
|
51
50
|
|
|
52
51
|
# Replace progress reporter for colors.
|
|
53
|
-
if
|
|
54
|
-
|
|
55
|
-
end
|
|
56
|
-
if minitest_reporter.reporters.reject! { |reporter| reporter.kind_of?(ProgressReporter) } != nil
|
|
57
|
-
minitest_reporter << ::Rails::TestUnitReporter.new(options[:io], options)
|
|
52
|
+
if reporter.reporters.reject! { |reporter| reporter.kind_of?(ProgressReporter) }
|
|
53
|
+
reporter << ::Rails::TestUnitReporter.new(options[:io], options)
|
|
58
54
|
end
|
|
59
55
|
end
|
|
60
56
|
|
|
61
|
-
#
|
|
57
|
+
# Backwards compatibility with Rails 5.0 generated plugin test scripts
|
|
62
58
|
mattr_reader :run_via, default: {}
|
|
63
59
|
end
|
data/lib/rails.rb
CHANGED
|
@@ -13,6 +13,7 @@ require "active_support/core_ext/object/blank"
|
|
|
13
13
|
|
|
14
14
|
require "rails/application"
|
|
15
15
|
require "rails/version"
|
|
16
|
+
require "rails/autoloaders"
|
|
16
17
|
|
|
17
18
|
require "active_support/railtie"
|
|
18
19
|
require "action_dispatch/railtie"
|
|
@@ -110,5 +111,9 @@ module Rails
|
|
|
110
111
|
def public_path
|
|
111
112
|
application && Pathname.new(application.paths["public"].first)
|
|
112
113
|
end
|
|
114
|
+
|
|
115
|
+
def autoloaders
|
|
116
|
+
Autoloaders
|
|
117
|
+
end
|
|
113
118
|
end
|
|
114
119
|
end
|
data/lib/rails/all.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# rubocop:disable Style/RedundantBegin
|
|
4
|
+
|
|
3
5
|
require "rails"
|
|
4
6
|
|
|
5
7
|
%w(
|
|
@@ -10,6 +12,8 @@ require "rails"
|
|
|
10
12
|
action_mailer/railtie
|
|
11
13
|
active_job/railtie
|
|
12
14
|
action_cable/engine
|
|
15
|
+
action_mailbox/engine
|
|
16
|
+
action_text/engine
|
|
13
17
|
rails/test_unit/railtie
|
|
14
18
|
sprockets/railtie
|
|
15
19
|
).each do |railtie|
|
data/lib/rails/api/generator.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "sdoc"
|
|
4
|
+
require "active_support/core_ext/array/extract"
|
|
4
5
|
|
|
5
6
|
class RDoc::Generator::API < RDoc::Generator::SDoc # :nodoc:
|
|
6
7
|
RDoc::RDoc.add_generator self
|
|
@@ -11,7 +12,7 @@ class RDoc::Generator::API < RDoc::Generator::SDoc # :nodoc:
|
|
|
11
12
|
# since they aren't nested under a definition of the `ActiveStorage` module.
|
|
12
13
|
if visited.empty?
|
|
13
14
|
classes = classes.reject { |klass| active_storage?(klass) }
|
|
14
|
-
core_exts
|
|
15
|
+
core_exts = classes.extract! { |klass| core_extension?(klass) }
|
|
15
16
|
|
|
16
17
|
super.unshift([ "Core extensions", "", "", build_core_ext_subtree(core_exts, visited) ])
|
|
17
18
|
else
|
data/lib/rails/api/task.rb
CHANGED
|
@@ -18,6 +18,7 @@ module Rails
|
|
|
18
18
|
include: %w(
|
|
19
19
|
README.rdoc
|
|
20
20
|
lib/active_record/**/*.rb
|
|
21
|
+
lib/arel.rb
|
|
21
22
|
)
|
|
22
23
|
},
|
|
23
24
|
|
|
@@ -74,6 +75,22 @@ module Rails
|
|
|
74
75
|
)
|
|
75
76
|
},
|
|
76
77
|
|
|
78
|
+
"actionmailbox" => {
|
|
79
|
+
include: %w(
|
|
80
|
+
README.md
|
|
81
|
+
app/**/action_mailbox/**/*.rb
|
|
82
|
+
lib/action_mailbox/**/*.rb
|
|
83
|
+
)
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
"actiontext" => {
|
|
87
|
+
include: %w(
|
|
88
|
+
README.md
|
|
89
|
+
app/**/action_text/**/*.rb
|
|
90
|
+
lib/action_text/**/*.rb
|
|
91
|
+
)
|
|
92
|
+
},
|
|
93
|
+
|
|
77
94
|
"railties" => {
|
|
78
95
|
include: %w(
|
|
79
96
|
README.rdoc
|
data/lib/rails/app_loader.rb
CHANGED
|
@@ -23,7 +23,7 @@ control:
|
|
|
23
23
|
# too that you may or may not want (like yarn)
|
|
24
24
|
|
|
25
25
|
If you already have Rails binstubs in source control, you might be
|
|
26
|
-
|
|
26
|
+
inadvertently overwriting them during deployment by using bundle install
|
|
27
27
|
with the --binstubs option.
|
|
28
28
|
|
|
29
29
|
If your application was created prior to Rails 4, here's how to upgrade:
|
|
@@ -49,7 +49,7 @@ EOS
|
|
|
49
49
|
if exe = find_executable
|
|
50
50
|
contents = File.read(exe)
|
|
51
51
|
|
|
52
|
-
if
|
|
52
|
+
if /(APP|ENGINE)_PATH/.match?(contents)
|
|
53
53
|
exec RUBY, exe, *ARGV
|
|
54
54
|
break # non reachable, hack to be able to stub exec in the test suite
|
|
55
55
|
elsif exe.end_with?("bin/rails") && contents.include?("This file was generated by Bundler")
|
data/lib/rails/app_updater.rb
CHANGED
|
@@ -21,12 +21,14 @@ 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"))
|
|
24
25
|
options[:skip_active_record] = !defined?(ActiveRecord::Railtie)
|
|
25
|
-
options[:skip_active_storage] = !defined?(ActiveRecord::Railtie)
|
|
26
|
+
options[:skip_active_storage] = !defined?(ActiveStorage::Engine) || !defined?(ActiveRecord::Railtie)
|
|
26
27
|
options[:skip_action_mailer] = !defined?(ActionMailer::Railtie)
|
|
27
28
|
options[:skip_action_cable] = !defined?(ActionCable::Engine)
|
|
28
29
|
options[:skip_sprockets] = !defined?(Sprockets::Railtie)
|
|
29
30
|
options[:skip_puma] = !defined?(Puma)
|
|
31
|
+
options[:skip_bootsnap] = !defined?(Bootsnap)
|
|
30
32
|
options[:skip_spring] = !defined?(Spring)
|
|
31
33
|
options
|
|
32
34
|
end
|
data/lib/rails/application.rb
CHANGED
|
@@ -7,6 +7,7 @@ require "active_support/key_generator"
|
|
|
7
7
|
require "active_support/message_verifier"
|
|
8
8
|
require "active_support/encrypted_configuration"
|
|
9
9
|
require "active_support/deprecation"
|
|
10
|
+
require "active_support/hash_with_indifferent_access"
|
|
10
11
|
require "rails/engine"
|
|
11
12
|
require "rails/secrets"
|
|
12
13
|
|
|
@@ -172,14 +173,9 @@ module Rails
|
|
|
172
173
|
def key_generator
|
|
173
174
|
# number of iterations selected based on consultation with the google security
|
|
174
175
|
# team. Details at https://github.com/rails/rails/pull/6952#issuecomment-7661220
|
|
175
|
-
@caching_key_generator ||=
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)
|
|
179
|
-
)
|
|
180
|
-
else
|
|
181
|
-
ActiveSupport::LegacyKeyGenerator.new(secrets.secret_token)
|
|
182
|
-
end
|
|
176
|
+
@caching_key_generator ||= ActiveSupport::CachingKeyGenerator.new(
|
|
177
|
+
ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)
|
|
178
|
+
)
|
|
183
179
|
end
|
|
184
180
|
|
|
185
181
|
# Returns a message verifier object.
|
|
@@ -232,7 +228,12 @@ module Rails
|
|
|
232
228
|
|
|
233
229
|
if yaml.exist?
|
|
234
230
|
require "erb"
|
|
235
|
-
|
|
231
|
+
config = YAML.load(ERB.new(yaml.read).result) || {}
|
|
232
|
+
config = (config["shared"] || {}).merge(config[env] || {})
|
|
233
|
+
|
|
234
|
+
ActiveSupport::OrderedOptions.new.tap do |options|
|
|
235
|
+
options.update(NonSymbolAccessDeprecatedHash.new(config))
|
|
236
|
+
end
|
|
236
237
|
else
|
|
237
238
|
raise "Could not load configuration. No such file - #{yaml}"
|
|
238
239
|
end
|
|
@@ -249,7 +250,6 @@ module Rails
|
|
|
249
250
|
super.merge(
|
|
250
251
|
"action_dispatch.parameter_filter" => config.filter_parameters,
|
|
251
252
|
"action_dispatch.redirect_filter" => config.filter_redirect,
|
|
252
|
-
"action_dispatch.secret_token" => secrets.secret_token,
|
|
253
253
|
"action_dispatch.secret_key_base" => secret_key_base,
|
|
254
254
|
"action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions,
|
|
255
255
|
"action_dispatch.show_detailed_exceptions" => config.consider_all_requests_local,
|
|
@@ -267,9 +267,11 @@ module Rails
|
|
|
267
267
|
"action_dispatch.cookies_serializer" => config.action_dispatch.cookies_serializer,
|
|
268
268
|
"action_dispatch.cookies_digest" => config.action_dispatch.cookies_digest,
|
|
269
269
|
"action_dispatch.cookies_rotations" => config.action_dispatch.cookies_rotations,
|
|
270
|
+
"action_dispatch.use_cookies_with_metadata" => config.action_dispatch.use_cookies_with_metadata,
|
|
270
271
|
"action_dispatch.content_security_policy" => config.content_security_policy,
|
|
271
272
|
"action_dispatch.content_security_policy_report_only" => config.content_security_policy_report_only,
|
|
272
|
-
"action_dispatch.content_security_policy_nonce_generator" => config.content_security_policy_nonce_generator
|
|
273
|
+
"action_dispatch.content_security_policy_nonce_generator" => config.content_security_policy_nonce_generator,
|
|
274
|
+
"action_dispatch.content_security_policy_nonce_directives" => config.content_security_policy_nonce_directives
|
|
273
275
|
)
|
|
274
276
|
end
|
|
275
277
|
end
|
|
@@ -348,7 +350,7 @@ module Rails
|
|
|
348
350
|
files, dirs = config.watchable_files.dup, config.watchable_dirs.dup
|
|
349
351
|
|
|
350
352
|
ActiveSupport::Dependencies.autoload_paths.each do |path|
|
|
351
|
-
dirs[path.to_s] = [:rb]
|
|
353
|
+
File.file?(path) ? files << path.to_s : dirs[path.to_s] = [:rb]
|
|
352
354
|
end
|
|
353
355
|
|
|
354
356
|
[files, dirs]
|
|
@@ -373,9 +375,7 @@ module Rails
|
|
|
373
375
|
@config ||= Application::Configuration.new(self.class.find_root(self.class.called_from))
|
|
374
376
|
end
|
|
375
377
|
|
|
376
|
-
|
|
377
|
-
@config = configuration
|
|
378
|
-
end
|
|
378
|
+
attr_writer :config
|
|
379
379
|
|
|
380
380
|
# Returns secrets added to config/secrets.yml.
|
|
381
381
|
#
|
|
@@ -400,27 +400,18 @@ module Rails
|
|
|
400
400
|
|
|
401
401
|
# Fallback to config.secret_key_base if secrets.secret_key_base isn't set
|
|
402
402
|
secrets.secret_key_base ||= config.secret_key_base
|
|
403
|
-
# Fallback to config.secret_token if secrets.secret_token isn't set
|
|
404
|
-
secrets.secret_token ||= config.secret_token
|
|
405
|
-
|
|
406
|
-
if secrets.secret_token.present?
|
|
407
|
-
ActiveSupport::Deprecation.warn(
|
|
408
|
-
"`secrets.secret_token` is deprecated in favor of `secret_key_base` and will be removed in Rails 6.0."
|
|
409
|
-
)
|
|
410
|
-
end
|
|
411
403
|
|
|
412
404
|
secrets
|
|
413
405
|
end
|
|
414
406
|
end
|
|
415
407
|
|
|
416
|
-
|
|
417
|
-
@secrets = secrets
|
|
418
|
-
end
|
|
408
|
+
attr_writer :secrets
|
|
419
409
|
|
|
420
410
|
# The secret_key_base is used as the input secret to the application's key generator, which in turn
|
|
421
411
|
# is used to create all MessageVerifiers/MessageEncryptors, including the ones that sign and encrypt cookies.
|
|
422
412
|
#
|
|
423
|
-
# In
|
|
413
|
+
# In development and test, this is randomly generated and stored in a
|
|
414
|
+
# temporary file in <tt>tmp/development_secret.txt</tt>.
|
|
424
415
|
#
|
|
425
416
|
# In all other environments, we look for it first in ENV["SECRET_KEY_BASE"],
|
|
426
417
|
# then credentials.secret_key_base, and finally secrets.secret_key_base. For most applications,
|
|
@@ -438,13 +429,17 @@ module Rails
|
|
|
438
429
|
# Decrypts the credentials hash as kept in +config/credentials.yml.enc+. This file is encrypted with
|
|
439
430
|
# the Rails master key, which is either taken from <tt>ENV["RAILS_MASTER_KEY"]</tt> or from loading
|
|
440
431
|
# +config/master.key+.
|
|
432
|
+
# If specific credentials file exists for current environment, it takes precedence, thus for +production+
|
|
433
|
+
# environment look first for +config/credentials/production.yml.enc+ with master key taken
|
|
434
|
+
# from <tt>ENV["RAILS_MASTER_KEY"]</tt> or from loading +config/credentials/production.key+.
|
|
435
|
+
# Default behavior can be overwritten by setting +config.credentials.content_path+ and +config.credentials.key_path+.
|
|
441
436
|
def credentials
|
|
442
|
-
@credentials ||= encrypted(
|
|
437
|
+
@credentials ||= encrypted(config.credentials.content_path, key_path: config.credentials.key_path)
|
|
443
438
|
end
|
|
444
439
|
|
|
445
440
|
# Shorthand to decrypt any encrypted configurations or files.
|
|
446
441
|
#
|
|
447
|
-
# For any file added with <tt>
|
|
442
|
+
# For any file added with <tt>rails encrypted:edit</tt> call +read+ to decrypt
|
|
448
443
|
# the file with the master key.
|
|
449
444
|
# The master key is either stored in +config/master.key+ or <tt>ENV["RAILS_MASTER_KEY"]</tt>.
|
|
450
445
|
#
|
|
@@ -581,7 +576,7 @@ module Rails
|
|
|
581
576
|
secret_key_base
|
|
582
577
|
elsif secret_key_base
|
|
583
578
|
raise ArgumentError, "`secret_key_base` for #{Rails.env} environment must be a type of String`"
|
|
584
|
-
|
|
579
|
+
else
|
|
585
580
|
raise ArgumentError, "Missing `secret_key_base` for '#{Rails.env}' environment, set this string with `rails credentials:edit`"
|
|
586
581
|
end
|
|
587
582
|
end
|
|
@@ -614,5 +609,52 @@ module Rails
|
|
|
614
609
|
def build_middleware
|
|
615
610
|
config.app_middleware + super
|
|
616
611
|
end
|
|
612
|
+
|
|
613
|
+
class NonSymbolAccessDeprecatedHash < HashWithIndifferentAccess # :nodoc:
|
|
614
|
+
def initialize(value = nil)
|
|
615
|
+
if value.is_a?(Hash)
|
|
616
|
+
value.each_pair { |k, v| self[k] = v }
|
|
617
|
+
else
|
|
618
|
+
super
|
|
619
|
+
end
|
|
620
|
+
end
|
|
621
|
+
|
|
622
|
+
def []=(key, value)
|
|
623
|
+
regular_writer(key.to_sym, convert_value(value, for: :assignment))
|
|
624
|
+
end
|
|
625
|
+
|
|
626
|
+
private
|
|
627
|
+
|
|
628
|
+
def convert_key(key)
|
|
629
|
+
unless key.kind_of?(Symbol)
|
|
630
|
+
ActiveSupport::Deprecation.warn(<<~MESSAGE.squish)
|
|
631
|
+
Accessing hashes returned from config_for by non-symbol keys
|
|
632
|
+
is deprecated and will be removed in Rails 6.1.
|
|
633
|
+
Use symbols for access instead.
|
|
634
|
+
MESSAGE
|
|
635
|
+
|
|
636
|
+
key = key.to_sym
|
|
637
|
+
end
|
|
638
|
+
|
|
639
|
+
key
|
|
640
|
+
end
|
|
641
|
+
|
|
642
|
+
def convert_value(value, options = {}) # :doc:
|
|
643
|
+
if value.is_a? Hash
|
|
644
|
+
if options[:for] == :to_hash
|
|
645
|
+
value.to_hash
|
|
646
|
+
else
|
|
647
|
+
self.class.new(value)
|
|
648
|
+
end
|
|
649
|
+
elsif value.is_a?(Array)
|
|
650
|
+
if options[:for] != :assignment || value.frozen?
|
|
651
|
+
value = value.dup
|
|
652
|
+
end
|
|
653
|
+
value.map! { |e| convert_value(e, options) }
|
|
654
|
+
else
|
|
655
|
+
value
|
|
656
|
+
end
|
|
657
|
+
end
|
|
658
|
+
end
|
|
617
659
|
end
|
|
618
660
|
end
|