railties 5.2.5 → 6.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of railties might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +184 -180
- data/MIT-LICENSE +1 -1
- data/RDOC_MAIN.rdoc +35 -28
- data/README.rdoc +1 -1
- data/lib/minitest/rails_plugin.rb +6 -10
- data/lib/rails/all.rb +4 -0
- data/lib/rails/api/generator.rb +2 -1
- data/lib/rails/api/task.rb +16 -0
- data/lib/rails/app_loader.rb +1 -1
- data/lib/rails/app_updater.rb +3 -1
- data/lib/rails/application.rb +21 -45
- data/lib/rails/application/configuration.rb +54 -12
- data/lib/rails/application/default_middleware_stack.rb +2 -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/actions.rb +0 -10
- data/lib/rails/command/base.rb +1 -5
- data/lib/rails/command/behavior.rb +4 -46
- data/lib/rails/command/environment_argument.rb +1 -11
- data/lib/rails/command/spellchecker.rb +58 -0
- data/lib/rails/commands/credentials/USAGE +19 -1
- data/lib/rails/commands/credentials/credentials_command.rb +42 -23
- data/lib/rails/commands/db/system/change/change_command.rb +20 -0
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +2 -2
- data/lib/rails/commands/dev/dev_command.rb +17 -0
- data/lib/rails/commands/encrypted/encrypted_command.rb +2 -3
- data/lib/rails/commands/help/help_command.rb +1 -1
- data/lib/rails/commands/initializers/initializers_command.rb +16 -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 +6 -6
- 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 +109 -48
- data/lib/rails/configuration.rb +1 -7
- data/lib/rails/engine.rb +3 -9
- data/lib/rails/engine/configuration.rb +3 -1
- data/lib/rails/gem_version.rb +4 -4
- data/lib/rails/generators.rb +11 -12
- data/lib/rails/generators/actions.rb +48 -37
- data/lib/rails/generators/app_base.rb +49 -89
- data/lib/rails/generators/app_name.rb +50 -0
- data/lib/rails/generators/base.rb +0 -4
- data/lib/rails/generators/database.rb +57 -0
- data/lib/rails/generators/erb/mailer/mailer_generator.rb +1 -1
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +1 -1
- data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +1 -1
- data/lib/rails/generators/generated_attribute.rb +17 -17
- data/lib/rails/generators/model_helpers.rb +8 -1
- data/lib/rails/generators/named_base.rb +1 -5
- data/lib/rails/generators/rails/app/app_generator.rb +37 -72
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +3 -6
- 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 +15 -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 +4 -5
- data/lib/rails/generators/rails/app/templates/bin/update.tt +6 -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/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/sqlserver.yml.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +3 -2
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +5 -12
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +6 -2
- 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 +4 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_0.rb.tt +33 -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 +3 -5
- 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 +2 -7
- data/lib/rails/generators/rails/app/templates/package.json.tt +7 -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 -8
- 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 +55 -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 -18
- 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 +1 -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/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/scaffold/scaffold_generator.rb +1 -1
- 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 +2 -2
- data/lib/rails/info_controller.rb +1 -1
- data/lib/rails/mailers_controller.rb +1 -1
- 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 +125 -117
- 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 +1 -0
- data/lib/rails/tasks/yarn.rake +1 -1
- 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 +30 -24
- data/lib/rails/commands/encrypted/USAGE +0 -28
- 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/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,4 +1,6 @@
|
|
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
|
@@ -6,43 +8,48 @@ create database-backed web applications according to the
|
|
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,15 +77,15 @@ 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}[
|
80
|
+
* {Getting Started with \Rails}[https://guides.rubyonrails.org/getting_started.html].
|
81
|
+
* {Ruby on \Rails Guides}[https://guides.rubyonrails.org].
|
75
82
|
* {The API Documentation}[http://api.rubyonrails.org].
|
76
83
|
* {Ruby on \Rails Tutorial}[https://www.railstutorial.org/book].
|
77
84
|
|
78
85
|
== Contributing
|
79
86
|
|
80
87
|
We encourage you to contribute to Ruby on \Rails! Please check out the
|
81
|
-
{Contributing to Ruby on \Rails guide}[
|
88
|
+
{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
89
|
|
83
90
|
Trying to report a possible security vulnerability in \Rails? Please
|
84
91
|
check out our {security policy}[http://rubyonrails.org/security/] for
|
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
|
|
@@ -43,18 +43,14 @@ 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
|
|
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
@@ -74,6 +74,22 @@ module Rails
|
|
74
74
|
)
|
75
75
|
},
|
76
76
|
|
77
|
+
"actionmailbox" => {
|
78
|
+
include: %w(
|
79
|
+
README.md
|
80
|
+
app/**/action_mailbox/**/*.rb
|
81
|
+
lib/action_mailbox/**/*.rb
|
82
|
+
)
|
83
|
+
},
|
84
|
+
|
85
|
+
"actiontext" => {
|
86
|
+
include: %w(
|
87
|
+
README.md
|
88
|
+
app/**/action_text/**/*.rb
|
89
|
+
lib/action_text/**/*.rb
|
90
|
+
)
|
91
|
+
},
|
92
|
+
|
77
93
|
"railties" => {
|
78
94
|
include: %w(
|
79
95
|
README.rdoc
|
data/lib/rails/app_loader.rb
CHANGED
@@ -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
@@ -172,14 +172,9 @@ module Rails
|
|
172
172
|
def key_generator
|
173
173
|
# number of iterations selected based on consultation with the google security
|
174
174
|
# 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
|
175
|
+
@caching_key_generator ||= ActiveSupport::CachingKeyGenerator.new(
|
176
|
+
ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)
|
177
|
+
)
|
183
178
|
end
|
184
179
|
|
185
180
|
# Returns a message verifier object.
|
@@ -232,7 +227,12 @@ module Rails
|
|
232
227
|
|
233
228
|
if yaml.exist?
|
234
229
|
require "erb"
|
235
|
-
|
230
|
+
config = YAML.load(ERB.new(yaml.read).result) || {}
|
231
|
+
config = (config["shared"] || {}).merge(config[env] || {})
|
232
|
+
|
233
|
+
ActiveSupport::OrderedOptions.new.tap do |config_as_ordered_options|
|
234
|
+
config_as_ordered_options.update(config.deep_symbolize_keys)
|
235
|
+
end
|
236
236
|
else
|
237
237
|
raise "Could not load configuration. No such file - #{yaml}"
|
238
238
|
end
|
@@ -249,7 +249,6 @@ module Rails
|
|
249
249
|
super.merge(
|
250
250
|
"action_dispatch.parameter_filter" => config.filter_parameters,
|
251
251
|
"action_dispatch.redirect_filter" => config.filter_redirect,
|
252
|
-
"action_dispatch.secret_token" => secrets.secret_token,
|
253
252
|
"action_dispatch.secret_key_base" => secret_key_base,
|
254
253
|
"action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions,
|
255
254
|
"action_dispatch.show_detailed_exceptions" => config.consider_all_requests_local,
|
@@ -267,6 +266,7 @@ module Rails
|
|
267
266
|
"action_dispatch.cookies_serializer" => config.action_dispatch.cookies_serializer,
|
268
267
|
"action_dispatch.cookies_digest" => config.action_dispatch.cookies_digest,
|
269
268
|
"action_dispatch.cookies_rotations" => config.action_dispatch.cookies_rotations,
|
269
|
+
"action_dispatch.use_cookies_with_metadata" => config.action_dispatch.use_cookies_with_metadata,
|
270
270
|
"action_dispatch.content_security_policy" => config.content_security_policy,
|
271
271
|
"action_dispatch.content_security_policy_report_only" => config.content_security_policy_report_only,
|
272
272
|
"action_dispatch.content_security_policy_nonce_generator" => config.content_security_policy_nonce_generator
|
@@ -373,9 +373,7 @@ module Rails
|
|
373
373
|
@config ||= Application::Configuration.new(self.class.find_root(self.class.called_from))
|
374
374
|
end
|
375
375
|
|
376
|
-
|
377
|
-
@config = configuration
|
378
|
-
end
|
376
|
+
attr_writer :config
|
379
377
|
|
380
378
|
# Returns secrets added to config/secrets.yml.
|
381
379
|
#
|
@@ -400,22 +398,12 @@ module Rails
|
|
400
398
|
|
401
399
|
# Fallback to config.secret_key_base if secrets.secret_key_base isn't set
|
402
400
|
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
401
|
|
412
402
|
secrets
|
413
403
|
end
|
414
404
|
end
|
415
405
|
|
416
|
-
|
417
|
-
@secrets = secrets
|
418
|
-
end
|
406
|
+
attr_writer :secrets
|
419
407
|
|
420
408
|
# The secret_key_base is used as the input secret to the application's key generator, which in turn
|
421
409
|
# is used to create all MessageVerifiers/MessageEncryptors, including the ones that sign and encrypt cookies.
|
@@ -426,8 +414,8 @@ module Rails
|
|
426
414
|
# then credentials.secret_key_base, and finally secrets.secret_key_base. For most applications,
|
427
415
|
# the correct place to store it is in the encrypted credentials file.
|
428
416
|
def secret_key_base
|
429
|
-
if Rails.env.
|
430
|
-
secrets.secret_key_base
|
417
|
+
if Rails.env.test? || Rails.env.development?
|
418
|
+
secrets.secret_key_base || Digest::MD5.hexdigest(self.class.name)
|
431
419
|
else
|
432
420
|
validate_secret_key_base(
|
433
421
|
ENV["SECRET_KEY_BASE"] || credentials.secret_key_base || secrets.secret_key_base
|
@@ -438,13 +426,17 @@ module Rails
|
|
438
426
|
# Decrypts the credentials hash as kept in +config/credentials.yml.enc+. This file is encrypted with
|
439
427
|
# the Rails master key, which is either taken from <tt>ENV["RAILS_MASTER_KEY"]</tt> or from loading
|
440
428
|
# +config/master.key+.
|
429
|
+
# If specific credentials file exists for current environment, it takes precedence, thus for +production+
|
430
|
+
# environment look first for +config/credentials/production.yml.enc+ with master key taken
|
431
|
+
# from <tt>ENV["RAILS_MASTER_KEY"]</tt> or from loading +config/credentials/production.key+.
|
432
|
+
# Default behavior can be overwritten by setting +config.credentials.content_path+ and +config.credentials.key_path+.
|
441
433
|
def credentials
|
442
|
-
@credentials ||= encrypted(
|
434
|
+
@credentials ||= encrypted(config.credentials.content_path, key_path: config.credentials.key_path)
|
443
435
|
end
|
444
436
|
|
445
437
|
# Shorthand to decrypt any encrypted configurations or files.
|
446
438
|
#
|
447
|
-
# For any file added with <tt>
|
439
|
+
# For any file added with <tt>rails encrypted:edit</tt> call +read+ to decrypt
|
448
440
|
# the file with the master key.
|
449
441
|
# The master key is either stored in +config/master.key+ or <tt>ENV["RAILS_MASTER_KEY"]</tt>.
|
450
442
|
#
|
@@ -581,29 +573,13 @@ module Rails
|
|
581
573
|
secret_key_base
|
582
574
|
elsif secret_key_base
|
583
575
|
raise ArgumentError, "`secret_key_base` for #{Rails.env} environment must be a type of String`"
|
584
|
-
|
576
|
+
else
|
585
577
|
raise ArgumentError, "Missing `secret_key_base` for '#{Rails.env}' environment, set this string with `rails credentials:edit`"
|
586
578
|
end
|
587
579
|
end
|
588
580
|
|
589
581
|
private
|
590
582
|
|
591
|
-
def generate_development_secret
|
592
|
-
if secrets.secret_key_base.nil?
|
593
|
-
key_file = Rails.root.join("tmp/development_secret.txt")
|
594
|
-
|
595
|
-
if !File.exist?(key_file)
|
596
|
-
random_key = SecureRandom.hex(64)
|
597
|
-
FileUtils.mkdir_p(key_file.dirname)
|
598
|
-
File.binwrite(key_file, random_key)
|
599
|
-
end
|
600
|
-
|
601
|
-
secrets.secret_key_base = File.binread(key_file)
|
602
|
-
end
|
603
|
-
|
604
|
-
secrets.secret_key_base
|
605
|
-
end
|
606
|
-
|
607
583
|
def build_request(env)
|
608
584
|
req = super
|
609
585
|
env["ORIGINAL_FULLPATH"] = req.fullpath
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "ipaddr"
|
3
4
|
require "active_support/core_ext/kernel/reporting"
|
4
5
|
require "active_support/file_update_checker"
|
5
6
|
require "rails/engine/configuration"
|
@@ -11,13 +12,13 @@ module Rails
|
|
11
12
|
attr_accessor :allow_concurrency, :asset_host, :autoflush_log,
|
12
13
|
:cache_classes, :cache_store, :consider_all_requests_local, :console,
|
13
14
|
:eager_load, :exceptions_app, :file_watcher, :filter_parameters,
|
14
|
-
:force_ssl, :helpers_paths, :logger, :log_formatter, :log_tags,
|
15
|
-
:railties_order, :relative_url_root, :secret_key_base,
|
15
|
+
:force_ssl, :helpers_paths, :hosts, :logger, :log_formatter, :log_tags,
|
16
|
+
:railties_order, :relative_url_root, :secret_key_base,
|
16
17
|
:ssl_options, :public_file_server,
|
17
18
|
:session_options, :time_zone, :reload_classes_only_on_change,
|
18
19
|
:beginning_of_week, :filter_redirect, :x, :enable_dependency_loading,
|
19
20
|
:read_encrypted_secrets, :log_level, :content_security_policy_report_only,
|
20
|
-
:content_security_policy_nonce_generator, :require_master_key
|
21
|
+
:content_security_policy_nonce_generator, :require_master_key, :credentials
|
21
22
|
|
22
23
|
attr_reader :encoding, :api_only, :loaded_config_version
|
23
24
|
|
@@ -29,6 +30,7 @@ module Rails
|
|
29
30
|
@filter_parameters = []
|
30
31
|
@filter_redirect = []
|
31
32
|
@helpers_paths = []
|
33
|
+
@hosts = Array(([IPAddr.new("0.0.0.0/0"), IPAddr.new("::/0"), "localhost"] if Rails.env.development?))
|
32
34
|
@public_file_server = ActiveSupport::OrderedOptions.new
|
33
35
|
@public_file_server.enabled = true
|
34
36
|
@public_file_server.index_name = "index"
|
@@ -48,7 +50,6 @@ module Rails
|
|
48
50
|
@autoflush_log = true
|
49
51
|
@log_formatter = ActiveSupport::Logger::SimpleFormatter.new
|
50
52
|
@eager_load = nil
|
51
|
-
@secret_token = nil
|
52
53
|
@secret_key_base = nil
|
53
54
|
@api_only = false
|
54
55
|
@debug_exception_response_format = nil
|
@@ -60,6 +61,9 @@ module Rails
|
|
60
61
|
@content_security_policy_nonce_generator = nil
|
61
62
|
@require_master_key = false
|
62
63
|
@loaded_config_version = nil
|
64
|
+
@credentials = ActiveSupport::OrderedOptions.new
|
65
|
+
@credentials.content_path = default_credentials_content_path
|
66
|
+
@credentials.key_path = default_credentials_key_path
|
63
67
|
end
|
64
68
|
|
65
69
|
def load_defaults(target_version)
|
@@ -92,10 +96,6 @@ module Rails
|
|
92
96
|
|
93
97
|
if respond_to?(:active_record)
|
94
98
|
active_record.cache_versioning = true
|
95
|
-
# Remove the temporary load hook from SQLite3Adapter when this is removed
|
96
|
-
ActiveSupport.on_load(:active_record_sqlite3adapter) do
|
97
|
-
ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer = true
|
98
|
-
end
|
99
99
|
end
|
100
100
|
|
101
101
|
if respond_to?(:action_dispatch)
|
@@ -114,6 +114,29 @@ module Rails
|
|
114
114
|
if respond_to?(:action_view)
|
115
115
|
action_view.form_with_generates_ids = true
|
116
116
|
end
|
117
|
+
when "6.0"
|
118
|
+
load_defaults "5.2"
|
119
|
+
|
120
|
+
if respond_to?(:action_view)
|
121
|
+
action_view.default_enforce_utf8 = false
|
122
|
+
end
|
123
|
+
|
124
|
+
if respond_to?(:action_dispatch)
|
125
|
+
action_dispatch.use_cookies_with_metadata = true
|
126
|
+
end
|
127
|
+
|
128
|
+
if respond_to?(:action_mailer)
|
129
|
+
action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
|
130
|
+
end
|
131
|
+
|
132
|
+
if respond_to?(:active_job)
|
133
|
+
active_job.return_false_on_aborted_enqueue = true
|
134
|
+
end
|
135
|
+
|
136
|
+
if respond_to?(:active_storage)
|
137
|
+
active_storage.queues.analysis = :active_storage_analysis
|
138
|
+
active_storage.queues.purge = :active_storage_purge
|
139
|
+
end
|
117
140
|
else
|
118
141
|
raise "Unknown version #{target_version.to_s.inspect}"
|
119
142
|
end
|
@@ -140,9 +163,7 @@ module Rails
|
|
140
163
|
@debug_exception_response_format || :default
|
141
164
|
end
|
142
165
|
|
143
|
-
|
144
|
-
@debug_exception_response_format = value
|
145
|
-
end
|
166
|
+
attr_writer :debug_exception_response_format
|
146
167
|
|
147
168
|
def paths
|
148
169
|
@paths ||= begin
|
@@ -235,7 +256,7 @@ module Rails
|
|
235
256
|
end
|
236
257
|
|
237
258
|
def annotations
|
238
|
-
SourceAnnotationExtractor::Annotation
|
259
|
+
Rails::SourceAnnotationExtractor::Annotation
|
239
260
|
end
|
240
261
|
|
241
262
|
def content_security_policy(&block)
|
@@ -265,6 +286,27 @@ module Rails
|
|
265
286
|
true
|
266
287
|
end
|
267
288
|
end
|
289
|
+
|
290
|
+
private
|
291
|
+
def default_credentials_content_path
|
292
|
+
if credentials_available_for_current_env?
|
293
|
+
root.join("config", "credentials", "#{Rails.env}.yml.enc")
|
294
|
+
else
|
295
|
+
root.join("config", "credentials.yml.enc")
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
def default_credentials_key_path
|
300
|
+
if credentials_available_for_current_env?
|
301
|
+
root.join("config", "credentials", "#{Rails.env}.key")
|
302
|
+
else
|
303
|
+
root.join("config", "master.key")
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
def credentials_available_for_current_env?
|
308
|
+
File.exist?(root.join("config", "credentials", "#{Rails.env}.yml.enc"))
|
309
|
+
end
|
268
310
|
end
|
269
311
|
end
|
270
312
|
end
|