railties 7.0.2.4 → 7.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c76fbb98150f6b4e094db3b0cdcd33e0ae0ecacf03c8f4b6dcc37a1be0332321
4
- data.tar.gz: 14cf08a67c5fc5005263ab4d4ba7d0ec0a99a193824a96802c86cd8adbe90a8a
3
+ metadata.gz: 8426dae672be312fe1692dddb173520cb38cab1d146901da4e8321a731c4d309
4
+ data.tar.gz: '086173aa65cfba04c54b052ad3725f2cb55caafc7b2eef3255883f86a51dea3b'
5
5
  SHA512:
6
- metadata.gz: fe2a28a0706d021a46eb8985cd573e3b8b761114a34de61d4a2bfa4b3f66ff70c2e9c40ecacf4e16899e4bd656bd897a11685812670acf09b49951d93de2c5d8
7
- data.tar.gz: '039ca72deb7c75f86d2430bd47b8de7b8b634f2453aac00cc14321158e3f5000c2b392396b7e71d7da8d975d032ec612f7396592059ec8d95b3c18009c3533a7'
6
+ metadata.gz: 3a936aed24714e95363c55d50c008a2d85a4b22951647172b79b7d5faaaa2b49dce611f43bc6099001cc400b91614a49f003f5c68834c218596434c2d6e5ae71
7
+ data.tar.gz: b863940381ffc5819d6cd191735d30af40603d04946630781ab01ba6d0b6ab3ead22449b95f99fca4f84bbfa06b85b6aa9d3d05cce5ab1df0bd2a8841420d76e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,73 @@
1
+ ## Rails 7.0.4 (September 09, 2022) ##
2
+
3
+ * `config.allow_concurrency = false` now use a `Monitor` instead of a `Mutex`
4
+
5
+ This allows to enable `config.active_support.executor_around_test_case` even
6
+ when `config.allow_concurrency` is disabled.
7
+
8
+ *Jean Boussier*
9
+
10
+ * Skip Active Storage and Action Mailer if Active Job is skipped.
11
+
12
+ *Étienne Barrié*
13
+
14
+ * Correctly check if frameworks are disabled when running app:update.
15
+
16
+ *Étienne Barrié* and *Paulo Barros*
17
+
18
+ * Fixed `config.active_support.cache_format_version` never being applied.
19
+
20
+ Rails 7.0 shipped with a new serializer for Rails.cache, but the associated config
21
+ wasn't working properly. Note that even after this fix, it can only be applied from
22
+ the `application.rb` file.
23
+
24
+ *Alex Ghiculescu*
25
+
26
+
27
+ ## Rails 7.0.3.1 (July 12, 2022) ##
28
+
29
+ * No changes.
30
+
31
+
32
+ ## Rails 7.0.3 (May 09, 2022) ##
33
+
34
+ * If reloading and eager loading are both enabled, after a reload Rails eager loads again the application code.
35
+
36
+ *Xavier Noria*
37
+
38
+ * Use `controller_class_path` in `Rails::Generators::NamedBase#route_url`
39
+
40
+ The `route_url` method now returns the correct path when generating
41
+ a namespaced controller with a top-level model using `--model-name`.
42
+
43
+ Previously, when running this command:
44
+
45
+ ``` sh
46
+ bin/rails generate scaffold_controller Admin/Post --model-name Post
47
+ ```
48
+
49
+ the comments above the controller action would look like:
50
+
51
+ ``` ruby
52
+ # GET /posts
53
+ def index
54
+ @posts = Post.all
55
+ end
56
+ ```
57
+
58
+ afterwards, they now look like this:
59
+
60
+ ``` ruby
61
+ # GET /admin/posts
62
+ def index
63
+ @posts = Post.all
64
+ end
65
+ ```
66
+
67
+ Fixes #44662.
68
+
69
+ *Andrew White*
70
+
1
71
  ## Rails 7.0.2.4 (April 26, 2022) ##
2
72
 
3
73
  * No changes.
@@ -49,7 +49,7 @@ module Minitest
49
49
  end
50
50
 
51
51
  # Owes great inspiration to test runner trailblazers like RSpec,
52
- # minitest-reporters, maxitest and others.
52
+ # minitest-reporters, maxitest, and others.
53
53
  def self.plugin_rails_init(options)
54
54
  unless options[:full_backtrace] || ENV["BACKTRACE"]
55
55
  # Plugin can run without Rails loaded, check before filtering.
@@ -21,10 +21,15 @@ module Rails
21
21
  private
22
22
  def generator_options
23
23
  options = { api: !!Rails.application.config.api_only, update: true }
24
+ options[:skip_active_job] = !defined?(ActiveJob::Railtie)
24
25
  options[:skip_active_record] = !defined?(ActiveRecord::Railtie)
25
- options[:skip_active_storage] = !defined?(ActiveStorage::Engine) || !defined?(ActiveRecord::Railtie)
26
+ options[:skip_active_storage] = !defined?(ActiveStorage::Engine)
26
27
  options[:skip_action_mailer] = !defined?(ActionMailer::Railtie)
28
+ options[:skip_action_mailbox] = !defined?(ActionMailbox::Engine)
29
+ options[:skip_action_text] = !defined?(ActionText::Engine)
27
30
  options[:skip_action_cable] = !defined?(ActionCable::Engine)
31
+ options[:skip_test] = !defined?(Rails::TestUnitRailtie)
32
+ options[:skip_system_test] = Rails.application.config.generators.system_tests.nil?
28
33
  options[:skip_asset_pipeline] = !defined?(Sprockets::Railtie) && !defined?(Propshaft::Railtie)
29
34
  options[:skip_bootsnap] = !defined?(Bootsnap)
30
35
  options[:updating] = true
@@ -59,6 +59,9 @@ module Rails
59
59
 
60
60
  # Initialize cache early in the stack so railties can make use of it.
61
61
  initializer :initialize_cache, group: :all do
62
+ cache_format_version = config.active_support.delete(:cache_format_version)
63
+ ActiveSupport.cache_format_version = cache_format_version if cache_format_version
64
+
62
65
  unless Rails.cache
63
66
  Rails.cache = ActiveSupport::Cache.lookup_store(*config.cache_store)
64
67
 
@@ -334,8 +334,14 @@ module Rails
334
334
  config = if yaml&.exist?
335
335
  loaded_yaml = ActiveSupport::ConfigurationFile.parse(yaml)
336
336
  if (shared = loaded_yaml.delete("shared"))
337
- loaded_yaml.each do |_k, values|
338
- values.reverse_merge!(shared)
337
+ loaded_yaml.each do |env, config|
338
+ if config.is_a?(Hash) && config.values.all?(Hash)
339
+ config.map do |name, sub_config|
340
+ sub_config.reverse_merge!(shared)
341
+ end
342
+ else
343
+ config.reverse_merge!(shared)
344
+ end
339
345
  end
340
346
  end
341
347
  Hash.new(shared).merge(loaded_yaml)
@@ -361,6 +367,20 @@ module Rails
361
367
  generators.colorize_logging = val
362
368
  end
363
369
 
370
+ # Specifies what class to use to store the session. Possible values
371
+ # are +:cookie_store+, +:mem_cache_store+, a custom store, or
372
+ # +:disabled+. +:disabled+ tells Rails not to deal with sessions.
373
+ #
374
+ # Additional options will be set as +session_options+:
375
+ #
376
+ # config.session_store :cookie_store, key: "_your_app_session"
377
+ # config.session_options # => {key: "_your_app_session"}
378
+ #
379
+ # If a custom store is specified as a symbol, it will be resolved to
380
+ # the +ActionDispatch::Session+ namespace:
381
+ #
382
+ # # use ActionDispatch::Session::MyCustomStore as the session store
383
+ # config.session_store :my_custom_store
364
384
  def session_store(new_session_store = nil, **options)
365
385
  if new_session_store
366
386
  if new_session_store == :active_record_store
@@ -396,6 +416,7 @@ module Rails
396
416
  Rails::SourceAnnotationExtractor::Annotation
397
417
  end
398
418
 
419
+ # Configures the ActionDispatch::ContentSecurityPolicy.
399
420
  def content_security_policy(&block)
400
421
  if block_given?
401
422
  @content_security_policy = ActionDispatch::ContentSecurityPolicy.new(&block)
@@ -404,6 +425,7 @@ module Rails
404
425
  end
405
426
  end
406
427
 
428
+ # Configures the ActionDispatch::PermissionsPolicy.
407
429
  def permissions_policy(&block)
408
430
  if block_given?
409
431
  @permissions_policy = ActionDispatch::PermissionsPolicy.new(&block)
@@ -81,6 +81,21 @@ module Rails
81
81
  middleware.use ::Rack::ETag, "no-cache"
82
82
 
83
83
  middleware.use ::Rack::TempfileReaper unless config.api_only
84
+
85
+ if config.respond_to?(:active_record)
86
+ if selector_options = config.active_record.database_selector
87
+ resolver = config.active_record.database_resolver
88
+ context = config.active_record.database_resolver_context
89
+
90
+ middleware.use ::ActiveRecord::Middleware::DatabaseSelector, resolver, context, selector_options
91
+ end
92
+
93
+ if shard_resolver = config.active_record.shard_resolver
94
+ options = config.active_record.shard_selector || {}
95
+
96
+ middleware.use ::ActiveRecord::Middleware::ShardSelector, shard_resolver, options
97
+ end
98
+ end
84
99
  end
85
100
  end
86
101
 
@@ -35,10 +35,6 @@ module Rails
35
35
  ActiveSupport::Dependencies._autoloaded_tracked_classes << value
36
36
  end
37
37
  end
38
-
39
- autoloader.on_unload do |_cpath, value, _abspath|
40
- value.before_remove_const if value.respond_to?(:before_remove_const)
41
- end
42
38
  end
43
39
 
44
40
  autoloader.setup
@@ -72,11 +68,17 @@ module Rails
72
68
  app.reloader.prepare!
73
69
  end
74
70
 
75
- initializer :eager_load! do
71
+ initializer :eager_load! do |app|
76
72
  if config.eager_load
77
73
  ActiveSupport.run_load_hooks(:before_eager_load, self)
78
74
  Zeitwerk::Loader.eager_load_all
79
75
  config.eager_load_namespaces.each(&:eager_load!)
76
+
77
+ unless config.cache_classes
78
+ app.reloader.after_class_unload do
79
+ Rails.autoloaders.main.eager_load
80
+ end
81
+ end
80
82
  end
81
83
  end
82
84
 
@@ -85,21 +87,21 @@ module Rails
85
87
  ActiveSupport.run_load_hooks(:after_initialize, self)
86
88
  end
87
89
 
88
- class MutexHook
89
- def initialize(mutex = Mutex.new)
90
- @mutex = mutex
90
+ class MonitorHook # :nodoc:
91
+ def initialize(monitor = Monitor.new)
92
+ @monitor = monitor
91
93
  end
92
94
 
93
95
  def run
94
- @mutex.lock
96
+ @monitor.enter
95
97
  end
96
98
 
97
99
  def complete(_state)
98
- @mutex.unlock
100
+ @monitor.exit
99
101
  end
100
102
  end
101
103
 
102
- module InterlockHook
104
+ module InterlockHook # :nodoc:
103
105
  def self.run
104
106
  ActiveSupport::Dependencies.interlock.start_running
105
107
  end
@@ -114,7 +116,7 @@ module Rails
114
116
  # User has explicitly opted out of concurrent request
115
117
  # handling: presumably their code is not threadsafe
116
118
 
117
- app.executor.register_hook(MutexHook.new, outer: true)
119
+ app.executor.register_hook(MonitorHook.new, outer: true)
118
120
 
119
121
  elsif config.allow_concurrency == :unsafe
120
122
  # Do nothing, even if we know this is dangerous. This is the
@@ -22,12 +22,12 @@ module Rails
22
22
  # Rails::Application::Bootstrap) and finishing initializers, after all the others
23
23
  # are executed (check Rails::Application::Finisher).
24
24
  #
25
- # == Configuration
25
+ # == \Configuration
26
26
  #
27
27
  # Besides providing the same configuration as Rails::Engine and Rails::Railtie,
28
28
  # the application object has several specific configurations, for example
29
- # "cache_classes", "consider_all_requests_local", "filter_parameters",
30
- # "logger" and so forth.
29
+ # +cache_classes+, +consider_all_requests_local+, +filter_parameters+,
30
+ # +logger+, and so forth.
31
31
  #
32
32
  # Check Rails::Application::Configuration to see them all.
33
33
  #
@@ -43,21 +43,21 @@ module Rails
43
43
  # == Booting process
44
44
  #
45
45
  # The application is also responsible for setting up and executing the booting
46
- # process. From the moment you require "config/application.rb" in your app,
46
+ # process. From the moment you require <tt>config/application.rb</tt> in your app,
47
47
  # the booting process goes like this:
48
48
  #
49
- # 1) require "config/boot.rb" to set up load paths
50
- # 2) require railties and engines
51
- # 3) Define Rails.application as "class MyApp::Application < Rails::Application"
52
- # 4) Run config.before_configuration callbacks
53
- # 5) Load config/environments/ENV.rb
54
- # 6) Run config.before_initialize callbacks
55
- # 7) Run Railtie#initializer defined by railties, engines and application.
56
- # One by one, each engine sets up its load paths, routes and runs its config/initializers/* files.
57
- # 8) Custom Railtie#initializers added by railties, engines and applications are executed
58
- # 9) Build the middleware stack and run to_prepare callbacks
59
- # 10) Run config.before_eager_load and eager_load! if eager_load is true
60
- # 11) Run config.after_initialize callbacks
49
+ # 1. <tt>require "config/boot.rb"</tt> to set up load paths.
50
+ # 2. +require+ railties and engines.
51
+ # 3. Define +Rails.application+ as <tt>class MyApp::Application < Rails::Application</tt>.
52
+ # 4. Run +config.before_configuration+ callbacks.
53
+ # 5. Load <tt>config/environments/ENV.rb</tt>.
54
+ # 6. Run +config.before_initialize+ callbacks.
55
+ # 7. Run <tt>Railtie#initializer</tt> defined by railties, engines, and application.
56
+ # One by one, each engine sets up its load paths and routes, and runs its <tt>config/initializers/*</tt> files.
57
+ # 8. Custom <tt>Railtie#initializers</tt> added by railties, engines, and applications are executed.
58
+ # 9. Build the middleware stack and run +to_prepare+ callbacks.
59
+ # 10. Run +config.before_eager_load+ and +eager_load!+ if +eager_load+ is +true+.
60
+ # 11. Run +config.after_initialize+ callbacks.
61
61
  class Application < Engine
62
62
  autoload :Bootstrap, "rails/application/bootstrap"
63
63
  autoload :Configuration, "rails/application/configuration"
@@ -175,7 +175,7 @@ module Rails
175
175
  # Rails.application.message_verifier('sensitive_data').verify(message)
176
176
  # # => 'my sensible data'
177
177
  #
178
- # See the +ActiveSupport::MessageVerifier+ documentation for more information.
178
+ # See the ActiveSupport::MessageVerifier documentation for more information.
179
179
  def message_verifier(verifier_name)
180
180
  @message_verifiers[verifier_name] ||= begin
181
181
  secret = key_generator.generate_key(verifier_name.to_s)
@@ -403,13 +403,14 @@ module Rails
403
403
  attr_writer :secrets, :credentials
404
404
 
405
405
  # The secret_key_base is used as the input secret to the application's key generator, which in turn
406
- # is used to create all MessageVerifiers/MessageEncryptors, including the ones that sign and encrypt cookies.
406
+ # is used to create all ActiveSupport::MessageVerifier and ActiveSupport::MessageEncryptor instances,
407
+ # including the ones that sign and encrypt cookies.
407
408
  #
408
409
  # In development and test, this is randomly generated and stored in a
409
410
  # temporary file in <tt>tmp/development_secret.txt</tt>.
410
411
  #
411
- # In all other environments, we look for it first in ENV["SECRET_KEY_BASE"],
412
- # then credentials.secret_key_base, and finally secrets.secret_key_base. For most applications,
412
+ # In all other environments, we look for it first in <tt>ENV["SECRET_KEY_BASE"]</tt>,
413
+ # then +credentials.secret_key_base+, and finally +secrets.secret_key_base+. For most applications,
413
414
  # the correct place to store it is in the encrypted credentials file.
414
415
  def secret_key_base
415
416
  if Rails.env.development? || Rails.env.test?
data/lib/rails/command.rb CHANGED
@@ -26,7 +26,7 @@ module Rails
26
26
  ENV["RAILS_ENV"].presence || ENV["RACK_ENV"].presence || "development"
27
27
  end
28
28
 
29
- # Receives a namespace, arguments and the behavior to invoke the command.
29
+ # Receives a namespace, arguments, and the behavior to invoke the command.
30
30
  def invoke(full_namespace, args = [], **config)
31
31
  namespace = full_namespace = full_namespace.to_s
32
32
 
@@ -263,8 +263,13 @@ module Rails
263
263
  MSG
264
264
  else
265
265
  error = CorrectableError.new("Could not find server '#{server}'.", server, RACK_SERVERS)
266
+ if error.respond_to?(:detailed_message)
267
+ formatted_message = error.detailed_message
268
+ else
269
+ formatted_message = error.message
270
+ end
266
271
  <<~MSG
267
- #{error.message}
272
+ #{formatted_message}
268
273
  Run `bin/rails server --help` for more options.
269
274
  MSG
270
275
  end
@@ -4,14 +4,14 @@ module Rails
4
4
  module ConsoleMethods
5
5
  # Gets the helper methods available to the controller.
6
6
  #
7
- # This method assumes an +ApplicationController+ exists, and it extends +ActionController::Base+
7
+ # This method assumes an +ApplicationController+ exists, and that it extends ActionController::Base.
8
8
  def helper
9
9
  ApplicationController.helpers
10
10
  end
11
11
 
12
12
  # Gets a new instance of a controller object.
13
13
  #
14
- # This method assumes an +ApplicationController+ exists, and it extends +ActionController::Base+
14
+ # This method assumes an +ApplicationController+ exists, and that it extends ActionController::Base.
15
15
  def controller
16
16
  @controller ||= ApplicationController.new
17
17
  end
data/lib/rails/engine.rb CHANGED
@@ -11,10 +11,10 @@ require "thread"
11
11
  module Rails
12
12
  # <tt>Rails::Engine</tt> allows you to wrap a specific Rails application or subset of
13
13
  # functionality and share it with other applications or within a larger packaged application.
14
- # Every <tt>Rails::Application</tt> is just an engine, which allows for simple
14
+ # Every Rails::Application is just an engine, which allows for simple
15
15
  # feature and application sharing.
16
16
  #
17
- # Any <tt>Rails::Engine</tt> is also a <tt>Rails::Railtie</tt>, so the same
17
+ # Any <tt>Rails::Engine</tt> is also a Rails::Railtie, so the same
18
18
  # methods (like <tt>rake_tasks</tt> and +generators+) and configuration
19
19
  # options that are available in railties can also be used in engines.
20
20
  #
@@ -31,7 +31,7 @@ module Rails
31
31
  # end
32
32
  #
33
33
  # Then ensure that this file is loaded at the top of your <tt>config/application.rb</tt>
34
- # (or in your +Gemfile+) and it will automatically load models, controllers and helpers
34
+ # (or in your +Gemfile+), and it will automatically load models, controllers, and helpers
35
35
  # inside +app+, load routes at <tt>config/routes.rb</tt>, load locales at
36
36
  # <tt>config/locales/**/*</tt>, and load tasks at <tt>lib/tasks/**/*</tt>.
37
37
  #
@@ -192,13 +192,13 @@ module Rails
192
192
  #
193
193
  # == Isolated Engine
194
194
  #
195
- # Normally when you create controllers, helpers and models inside an engine, they are treated
195
+ # Normally when you create controllers, helpers, and models inside an engine, they are treated
196
196
  # as if they were created inside the application itself. This means that all helpers and
197
197
  # named routes from the application will be available to your engine's controllers as well.
198
198
  #
199
199
  # However, sometimes you want to isolate your engine from the application, especially if your engine
200
200
  # has its own router. To do that, you simply need to call +isolate_namespace+. This method requires
201
- # you to pass a module where all your controllers, helpers and models should be nested to:
201
+ # you to pass a module where all your controllers, helpers, and models should be nested to:
202
202
  #
203
203
  # module MyEngine
204
204
  # class Engine < Rails::Engine
@@ -236,9 +236,9 @@ module Rails
236
236
  # +articles_path+, like you would do with your main application.
237
237
  #
238
238
  # To make this behavior consistent with other parts of the framework,
239
- # isolated engines also have an effect on <tt>ActiveModel::Naming</tt>. In a
239
+ # isolated engines also have an effect on ActiveModel::Naming. In a
240
240
  # normal Rails app, when you use a namespaced model such as
241
- # <tt>Namespace::Article</tt>, <tt>ActiveModel::Naming</tt> will generate
241
+ # <tt>Namespace::Article</tt>, ActiveModel::Naming will generate
242
242
  # names with the prefix "namespace". In an isolated engine, the prefix will
243
243
  # be omitted in URL helpers and form fields, for convenience.
244
244
  #
@@ -442,7 +442,7 @@ module Rails
442
442
  end
443
443
 
444
444
  # Load console and invoke the registered hooks.
445
- # Check <tt>Rails::Railtie.console</tt> for more info.
445
+ # Check Rails::Railtie.console for more info.
446
446
  def load_console(app = self)
447
447
  require "rails/console/app"
448
448
  require "rails/console/helpers"
@@ -451,14 +451,14 @@ module Rails
451
451
  end
452
452
 
453
453
  # Load Rails runner and invoke the registered hooks.
454
- # Check <tt>Rails::Railtie.runner</tt> for more info.
454
+ # Check Rails::Railtie.runner for more info.
455
455
  def load_runner(app = self)
456
456
  run_runner_blocks(app)
457
457
  self
458
458
  end
459
459
 
460
- # Load Rake, railties tasks and invoke the registered hooks.
461
- # Check <tt>Rails::Railtie.rake_tasks</tt> for more info.
460
+ # Load Rake and railties tasks, and invoke the registered hooks.
461
+ # Check Rails::Railtie.rake_tasks for more info.
462
462
  def load_tasks(app = self)
463
463
  require "rake"
464
464
  run_tasks_blocks(app)
@@ -466,7 +466,7 @@ module Rails
466
466
  end
467
467
 
468
468
  # Load Rails generators and invoke the registered hooks.
469
- # Check <tt>Rails::Railtie.generators</tt> for more info.
469
+ # Check Rails::Railtie.generators for more info.
470
470
  def load_generators(app = self)
471
471
  require "rails/generators"
472
472
  run_generators_blocks(app)
@@ -475,7 +475,7 @@ module Rails
475
475
  end
476
476
 
477
477
  # Invoke the server registered hooks.
478
- # Check <tt>Rails::Railtie.server</tt> for more info.
478
+ # Check Rails::Railtie.server for more info.
479
479
  def load_server(app = self)
480
480
  run_server_blocks(app)
481
481
  self
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rails
4
- # Returns the version of the currently loaded Rails as a <tt>Gem::Version</tt>
4
+ # Returns the currently loaded version of Rails as a <tt>Gem::Version</tt>.
5
5
  def self.gem_version
6
6
  Gem::Version.new VERSION::STRING
7
7
  end
@@ -9,8 +9,8 @@ module Rails
9
9
  module VERSION
10
10
  MAJOR = 7
11
11
  MINOR = 0
12
- TINY = 2
13
- PRE = "4"
12
+ TINY = 4
13
+ PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -187,12 +187,12 @@ module Rails
187
187
  [
188
188
  options.values_at(
189
189
  :skip_active_record,
190
- :skip_action_mailer,
191
190
  :skip_test,
192
191
  :skip_action_cable,
193
192
  :skip_active_job
194
193
  ),
195
194
  skip_active_storage?,
195
+ skip_action_mailer?,
196
196
  skip_action_mailbox?,
197
197
  skip_action_text?
198
198
  ].flatten.none?
@@ -220,7 +220,11 @@ module Rails
220
220
  end
221
221
 
222
222
  def skip_active_storage? # :doc:
223
- options[:skip_active_storage] || options[:skip_active_record]
223
+ options[:skip_active_storage] || options[:skip_active_record] || options[:skip_active_job]
224
+ end
225
+
226
+ def skip_action_mailer? # :doc:
227
+ options[:skip_action_mailer] || options[:skip_active_job]
224
228
  end
225
229
 
226
230
  def skip_action_mailbox? # :doc:
@@ -239,6 +243,10 @@ module Rails
239
243
  options[:skip_asset_pipeline] || options[:asset_pipeline] != "sprockets"
240
244
  end
241
245
 
246
+ def skip_propshaft?
247
+ options[:skip_asset_pipeline] || options[:asset_pipeline] != "propshaft"
248
+ end
249
+
242
250
 
243
251
  class GemfileEntry < Struct.new(:name, :version, :comment, :options, :commented_out)
244
252
  def initialize(name, version, comment, options = {}, commented_out = false)
@@ -94,7 +94,7 @@ module Rails
94
94
  #
95
95
  # The first and last part used to find the generator to be invoked are
96
96
  # guessed based on class invokes hook_for, as noticed in the example above.
97
- # This can be customized with two options: :in and :as.
97
+ # This can be customized with two options: +:in+ and +:as+.
98
98
  #
99
99
  # Let's suppose you are creating a generator that needs to invoke the
100
100
  # controller generator from test unit. Your first attempt is:
@@ -108,7 +108,7 @@ module Rails
108
108
  # "test_unit:awesome", "test_unit"
109
109
  #
110
110
  # Which is not the desired lookup. You can change it by providing the
111
- # :as option:
111
+ # +:as+ option:
112
112
  #
113
113
  # class AwesomeGenerator < Rails::Generators::Base
114
114
  # hook_for :test_framework, as: :controller
@@ -119,7 +119,7 @@ module Rails
119
119
  # "test_unit:controller", "test_unit"
120
120
  #
121
121
  # Similarly, if you want it to also look up in the rails namespace, you
122
- # just need to provide the :in value:
122
+ # just need to provide the +:in+ value:
123
123
  #
124
124
  # class AwesomeGenerator < Rails::Generators::Base
125
125
  # hook_for :test_framework, in: :rails, as: :controller
@@ -127,7 +127,7 @@ module Rails
127
127
  end
128
128
 
129
129
  def route_url # :doc:
130
- @route_url ||= class_path.collect { |dname| "/" + dname }.join + "/" + plural_file_name
130
+ @route_url ||= controller_class_path.collect { |dname| "/" + dname }.join + "/" + plural_file_name
131
131
  end
132
132
 
133
133
  def url_helper_prefix # :doc:
@@ -202,7 +202,7 @@ module Rails
202
202
  end
203
203
 
204
204
  # Add a class collisions name to be checked on class initialization. You
205
- # can supply a hash with a :prefix or :suffix to be tested.
205
+ # can supply a hash with a +:prefix+ or +:suffix+ to be tested.
206
206
  #
207
207
  # ==== Examples
208
208
  #
@@ -138,7 +138,7 @@ module Rails
138
138
  template "config/storage.yml"
139
139
  end
140
140
 
141
- if skip_sprockets? && !assets_config_exist
141
+ if skip_sprockets? && skip_propshaft? && !assets_config_exist
142
142
  remove_file "config/initializers/assets.rb"
143
143
  end
144
144
 
@@ -457,9 +457,12 @@ module Rails
457
457
  end
458
458
  end
459
459
 
460
- def delete_assets_initializer_skipping_sprockets
461
- if skip_sprockets?
460
+ def delete_assets_initializer_skipping_sprockets_and_propshaft
461
+ if skip_sprockets? && skip_propshaft?
462
462
  remove_file "config/initializers/assets.rb"
463
+ end
464
+
465
+ if skip_sprockets?
463
466
  remove_file "app/assets/config/manifest.js"
464
467
  remove_dir "app/assets/config"
465
468
  remove_file "app/assets/stylesheets/application.css"
@@ -1,8 +1,8 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- # Define an application-wide content security policy
4
- # For further information see the following documentation
5
- # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
3
+ # Define an application-wide content security policy.
4
+ # See the Securing Rails Applications Guide for more information:
5
+ # https://guides.rubyonrails.org/security.html#content-security-policy-header
6
6
 
7
7
  # Rails.application.configure do
8
8
  # config.content_security_policy do |policy|
@@ -20,7 +20,6 @@
20
20
  # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
21
21
  # config.content_security_policy_nonce_directives = %w(script-src)
22
22
  #
23
- # # Report CSP violations to a specified URI. See:
24
- # # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
23
+ # # Report violations without enforcing the policy.
25
24
  # # config.content_security_policy_report_only = true
26
25
  # end
@@ -34,13 +34,6 @@
34
34
  # implementation.
35
35
  # Rails.application.config.active_support.remove_deprecated_time_with_zone_name = true
36
36
 
37
- # Change the format of the cache entry.
38
- # Changing this default means that all new cache entries added to the cache
39
- # will have a different format that is not supported by Rails 6.1 applications.
40
- # Only change this value after your application is fully deployed to Rails 7.0
41
- # and you have no plans to rollback.
42
- # Rails.application.config.active_support.cache_format_version = 7.0
43
-
44
37
  # Calls `Rails.application.executor.wrap` around test cases.
45
38
  # This makes test cases behave closer to an actual request or job.
46
39
  # Several features that are normally disabled in test, such as Active Record query cache
@@ -71,7 +64,7 @@
71
64
  # This default means that all columns will be referenced in INSERT queries
72
65
  # regardless of whether they have a default or not.
73
66
  # Rails.application.config.active_record.partial_inserts = false
74
- #
67
+
75
68
  # Protect from open redirect attacks in `redirect_back_or_to` and `redirect_to`.
76
69
  # Rails.application.config.action_controller.raise_on_open_redirects = true
77
70
 
@@ -82,18 +75,6 @@
82
75
  # The `:mini_magick` option is not deprecated; it's fine to keep using it.
83
76
  # Rails.application.config.active_storage.variant_processor = :vips
84
77
 
85
- # If you're upgrading and haven't set `cookies_serializer` previously, your cookie serializer
86
- # was `:marshal`. Convert all cookies to JSON, using the `:hybrid` formatter.
87
- #
88
- # If you're confident all your cookies are JSON formatted, you can switch to the `:json` formatter.
89
- #
90
- # Continue to use `:marshal` for backward-compatibility with old cookies.
91
- #
92
- # If you have configured the serializer elsewhere, you can remove this.
93
- #
94
- # See https://guides.rubyonrails.org/action_controller_overview.html#cookies for more information.
95
- # Rails.application.config.action_dispatch.cookies_serializer = :hybrid
96
-
97
78
  # Enable parameter wrapping for JSON.
98
79
  # Previously this was set in an initializer. It's fine to keep using that initializer if you've customized it.
99
80
  # To disable parameter wrapping entirely, set this config to `false`.
@@ -115,3 +96,40 @@
115
96
  # "X-Permitted-Cross-Domain-Policies" => "none",
116
97
  # "Referrer-Policy" => "strict-origin-when-cross-origin"
117
98
  # }
99
+
100
+
101
+ # ** Please read carefully, this must be configured in config/application.rb **
102
+ # Change the format of the cache entry.
103
+ # Changing this default means that all new cache entries added to the cache
104
+ # will have a different format that is not supported by Rails 6.1 applications.
105
+ # Only change this value after your application is fully deployed to Rails 7.0
106
+ # and you have no plans to rollback.
107
+ # When you're ready to change format, add this to `config/application.rb` (NOT this file):
108
+ # config.active_support.cache_format_version = 7.0
109
+
110
+
111
+ # Cookie serializer: 2 options
112
+ #
113
+ # If you're upgrading and haven't set `cookies_serializer` previously, your cookie serializer
114
+ # is `:marshal`. The default for new apps is `:json`.
115
+ #
116
+ # Rails.application.config.action_dispatch.cookies_serializer = :json
117
+ #
118
+ #
119
+ # To migrate an existing application to the `:json` serializer, use the `:hybrid` option.
120
+ #
121
+ # Rails transparently deserializes existing (Marshal-serialized) cookies on read and
122
+ # re-writes them in the JSON format.
123
+ #
124
+ # It is fine to use `:hybrid` long term; you should do that until you're confident *all* your cookies
125
+ # have been converted to JSON. To keep using `:hybrid` long term, move this config to its own
126
+ # initializer or to `config/application.rb`.
127
+ #
128
+ # Rails.application.config.action_dispatch.cookies_serializer = :hybrid
129
+ #
130
+ #
131
+ # If your cookies can't yet be serialized to JSON, keep using `:marshal` for backward-compatibility.
132
+ #
133
+ # If you have configured the serializer elsewhere, you can remove this section of the file.
134
+ #
135
+ # See https://guides.rubyonrails.org/action_controller_overview.html#cookies for more information.
@@ -253,8 +253,8 @@ module Rails
253
253
  invoke_fallbacks_for(name, base) || invoke_fallbacks_for(context, name)
254
254
  end
255
255
 
256
- # Receives a namespace, arguments and the behavior to invoke the generator.
257
- # It's used as the default entry point for generate, destroy and update
256
+ # Receives a namespace, arguments, and the behavior to invoke the generator.
257
+ # It's used as the default entry point for generate, destroy, and update
258
258
  # commands.
259
259
  def invoke(namespace, args = ARGV, config = {})
260
260
  names = namespace.to_s.split(":")
@@ -266,8 +266,14 @@ module Rails
266
266
  options = sorted_groups.flat_map(&:last)
267
267
  error = Command::Base::CorrectableError.new("Could not find generator '#{namespace}'.", namespace, options)
268
268
 
269
+ if error.respond_to?(:detailed_message)
270
+ formatted_message = error.detailed_message
271
+ else
272
+ formatted_message = error.message
273
+ end
274
+
269
275
  puts <<~MSG
270
- #{error.message}
276
+ #{formatted_message}
271
277
  Run `bin/rails generate --help` for more options.
272
278
  MSG
273
279
  end
data/lib/rails/paths.rb CHANGED
@@ -12,7 +12,7 @@ module Rails
12
12
  # root.add "app/controllers", eager_load: true
13
13
  #
14
14
  # The above command creates a new root object and adds "app/controllers" as a path.
15
- # This means we can get a <tt>Rails::Paths::Path</tt> object back like below:
15
+ # This means we can get a Rails::Paths::Path object back like below:
16
16
  #
17
17
  # path = root["app/controllers"]
18
18
  # path.eager_load? # => true
@@ -31,13 +31,17 @@ module Rails
31
31
  private
32
32
  def call_app(request, env) # :doc:
33
33
  instrumenter = ActiveSupport::Notifications.instrumenter
34
- instrumenter.start "request.action_dispatch", request: request
34
+ instrumenter_state = instrumenter.start "request.action_dispatch", request: request
35
+ instrumenter_finish = -> () {
36
+ instrumenter.finish_with_state(instrumenter_state, "request.action_dispatch", request: request)
37
+ }
38
+
35
39
  logger.info { started_request_message(request) }
36
40
  status, headers, body = @app.call(env)
37
- body = ::Rack::BodyProxy.new(body) { finish(request) }
41
+ body = ::Rack::BodyProxy.new(body, &instrumenter_finish)
38
42
  [status, headers, body]
39
43
  rescue Exception
40
- finish(request)
44
+ instrumenter_finish.call
41
45
  raise
42
46
  ensure
43
47
  ActiveSupport::LogSubscriber.flush_all!
@@ -65,11 +69,6 @@ module Rails
65
69
  end
66
70
  end
67
71
 
68
- def finish(request)
69
- instrumenter = ActiveSupport::Notifications.instrumenter
70
- instrumenter.finish "request.action_dispatch", request: request
71
- end
72
-
73
72
  def logger
74
73
  Rails.logger
75
74
  end
data/lib/rails/railtie.rb CHANGED
@@ -24,7 +24,7 @@ module Rails
24
24
  # * creating initializers
25
25
  # * configuring a Rails framework for the application, like setting a generator
26
26
  # * adding <tt>config.*</tt> keys to the environment
27
- # * setting up a subscriber with <tt>ActiveSupport::Notifications</tt>
27
+ # * setting up a subscriber with ActiveSupport::Notifications
28
28
  # * adding Rake tasks
29
29
  #
30
30
  # == Creating a Railtie
@@ -129,7 +129,7 @@ module Rails
129
129
  # == Application and Engine
130
130
  #
131
131
  # An engine is nothing more than a railtie with some initializers already set. And since
132
- # <tt>Rails::Application</tt> is an engine, the same configuration described here can be
132
+ # Rails::Application is an engine, the same configuration described here can be
133
133
  # used in both.
134
134
  #
135
135
  # Be sure to look at the documentation of those specific classes for more information.
@@ -214,13 +214,15 @@ module Rails
214
214
  end
215
215
 
216
216
  def respond_to_missing?(name, _)
217
+ return super if abstract_railtie?
218
+
217
219
  instance.respond_to?(name) || super
218
220
  end
219
221
 
220
222
  # If the class method does not have a method, then send the method call
221
223
  # to the Railtie instance.
222
224
  def method_missing(name, *args, &block)
223
- if instance.respond_to?(name)
225
+ if !abstract_railtie? && instance.respond_to?(name)
224
226
  instance.public_send(name, *args, &block)
225
227
  else
226
228
  super
@@ -247,6 +249,10 @@ module Rails
247
249
  end
248
250
  end
249
251
 
252
+ def inspect # :nodoc:
253
+ "#<#{self.class.name}>"
254
+ end
255
+
250
256
  def configure(&block) # :nodoc:
251
257
  instance_eval(&block)
252
258
  end
@@ -70,7 +70,7 @@ module Rails
70
70
  #
71
71
  # If +options+ has a <tt>:tag</tt> flag, it will be passed to each annotation's +to_s+.
72
72
  #
73
- # See <tt>#find_in</tt> for a list of file extensions that will be taken into account.
73
+ # See SourceAnnotationExtractor#find_in for a list of file extensions that will be taken into account.
74
74
  #
75
75
  # This class method is the single entry point for the <tt>rails notes</tt> command.
76
76
  def self.enumerate(tag = nil, options = {})
data/lib/rails/version.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require_relative "gem_version"
4
4
 
5
5
  module Rails
6
- # Returns the version of the currently loaded Rails as a string.
6
+ # Returns the currently loaded version of Rails as a string.
7
7
  def self.version
8
8
  VERSION::STRING
9
9
  end
data/lib/rails.rb CHANGED
@@ -80,6 +80,13 @@ module Rails
80
80
  @_env = ActiveSupport::EnvironmentInquirer.new(environment)
81
81
  end
82
82
 
83
+ # Returns the ActiveSupport::ErrorReporter of the current Rails project,
84
+ # otherwise it returns +nil+ if there is no project.
85
+ #
86
+ # Rails.error.handle(IOError) do
87
+ # # ...
88
+ # end
89
+ # Rails.error.report(error)
83
90
  def error
84
91
  application && application.executor.error_reporter
85
92
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railties
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.2.4
4
+ version: 7.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-26 00:00:00.000000000 Z
11
+ date: 2022-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 7.0.2.4
19
+ version: 7.0.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 7.0.2.4
26
+ version: 7.0.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: actionpack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 7.0.2.4
33
+ version: 7.0.4
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 7.0.2.4
40
+ version: 7.0.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 7.0.2.4
103
+ version: 7.0.4
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 7.0.2.4
110
+ version: 7.0.4
111
111
  description: 'Rails internals: application bootup, plugins, generators, and rake tasks.'
112
112
  email: david@loudthinking.com
113
113
  executables:
@@ -422,10 +422,10 @@ licenses:
422
422
  - MIT
423
423
  metadata:
424
424
  bug_tracker_uri: https://github.com/rails/rails/issues
425
- changelog_uri: https://github.com/rails/rails/blob/v7.0.2.4/railties/CHANGELOG.md
426
- documentation_uri: https://api.rubyonrails.org/v7.0.2.4/
425
+ changelog_uri: https://github.com/rails/rails/blob/v7.0.4/railties/CHANGELOG.md
426
+ documentation_uri: https://api.rubyonrails.org/v7.0.4/
427
427
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
428
- source_code_uri: https://github.com/rails/rails/tree/v7.0.2.4/railties
428
+ source_code_uri: https://github.com/rails/rails/tree/v7.0.4/railties
429
429
  rubygems_mfa_required: 'true'
430
430
  post_install_message:
431
431
  rdoc_options:
@@ -444,7 +444,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
444
444
  - !ruby/object:Gem::Version
445
445
  version: '0'
446
446
  requirements: []
447
- rubygems_version: 3.1.6
447
+ rubygems_version: 3.3.3
448
448
  signing_key:
449
449
  specification_version: 4
450
450
  summary: Tools for creating, working with, and running Rails applications.