railties 8.0.0.beta1 → 8.0.0.rc2

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -0
  3. data/lib/rails/application/bootstrap.rb +0 -1
  4. data/lib/rails/application/configuration.rb +2 -12
  5. data/lib/rails/application/finisher.rb +0 -1
  6. data/lib/rails/command.rb +0 -6
  7. data/lib/rails/commands/console/irb_console.rb +11 -8
  8. data/lib/rails/commands/devcontainer/devcontainer_command.rb +1 -0
  9. data/lib/rails/console/methods.rb +5 -21
  10. data/lib/rails/engine/lazy_route_set.rb +11 -6
  11. data/lib/rails/engine.rb +2 -3
  12. data/lib/rails/gem_version.rb +1 -1
  13. data/lib/rails/generators/app_base.rb +0 -4
  14. data/lib/rails/generators/base.rb +0 -4
  15. data/lib/rails/generators/erb/authentication/authentication_generator.rb +3 -3
  16. data/lib/rails/generators/erb/authentication/templates/{views → app/views}/passwords/edit.html.erb +1 -1
  17. data/lib/rails/generators/rails/app/app_generator.rb +3 -1
  18. data/lib/rails/generators/rails/app/templates/Dockerfile.tt +1 -1
  19. data/lib/rails/generators/rails/app/templates/Gemfile.tt +3 -3
  20. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +2 -2
  21. data/lib/rails/generators/rails/app/templates/bin/setup.tt +0 -1
  22. data/lib/rails/generators/rails/app/templates/config/deploy.yml.tt +7 -3
  23. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_8_0.rb.tt +5 -0
  24. data/lib/rails/generators/rails/app/templates/github/ci.yml.tt +4 -0
  25. data/lib/rails/generators/rails/authentication/authentication_generator.rb +16 -12
  26. data/lib/rails/generators/rails/authentication/templates/app/channels/application_cable/connection.rb.tt +16 -0
  27. data/lib/rails/generators/rails/authentication/templates/{controllers/concerns/authentication.rb → app/controllers/concerns/authentication.rb.tt} +3 -3
  28. data/lib/rails/generators/rails/authentication/templates/{controllers/passwords_controller.rb → app/controllers/passwords_controller.rb.tt} +4 -4
  29. data/lib/rails/generators/rails/authentication/templates/{controllers/sessions_controller.rb → app/controllers/sessions_controller.rb.tt} +2 -2
  30. data/lib/rails/generators/rails/authentication/templates/{models/user.rb → app/models/user.rb.tt} +1 -1
  31. data/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb +8 -0
  32. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/Dockerfile.tt +1 -1
  33. data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +1 -1
  34. data/lib/rails/generators/test_unit/authentication/authentication_generator.rb +14 -0
  35. data/lib/rails/generators/test_unit/authentication/templates/test/fixtures/users.yml.tt +9 -0
  36. data/lib/rails/generators/test_unit/authentication/templates/test/models/user_test.rb.tt +7 -0
  37. data/lib/rails/test_unit/runner.rb +1 -0
  38. metadata +28 -26
  39. data/lib/rails/console/app.rb +0 -8
  40. data/lib/rails/console/helpers.rb +0 -8
  41. /data/lib/rails/generators/erb/authentication/templates/{views → app/views}/passwords/new.html.erb +0 -0
  42. /data/lib/rails/generators/erb/authentication/templates/{views → app/views}/sessions/new.html.erb +0 -0
  43. /data/lib/rails/generators/rails/authentication/templates/{mailers/passwords_mailer.rb → app/mailers/passwords_mailer.rb.tt} +0 -0
  44. /data/lib/rails/generators/rails/authentication/templates/{models/current.rb → app/models/current.rb.tt} +0 -0
  45. /data/lib/rails/generators/rails/authentication/templates/{models/session.rb → app/models/session.rb.tt} +0 -0
  46. /data/lib/rails/generators/rails/authentication/templates/{views/passwords_mailer/reset.html.erb → app/views/passwords_mailer/reset.html.erb.tt} +0 -0
  47. /data/lib/rails/generators/rails/authentication/templates/{views/passwords_mailer/reset.text.erb → app/views/passwords_mailer/reset.text.erb.tt} +0 -0
  48. /data/lib/rails/generators/rails/authentication/templates/test/mailers/previews/{passwords_mailer_preview.rb → passwords_mailer_preview.rb.tt} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e33b7c8f20e79a1706cdcad58be19d009563111e20a59f96d8c387d4088883c
4
- data.tar.gz: 4490c2625c393ab52a69d98a61caaa3a3b3f5093899e8203dad3d28a8a5dbc99
3
+ metadata.gz: 8f9ae335123309d95f081a813b7383b2c9b2a5ae07de08a1231fed3fe6098f0f
4
+ data.tar.gz: 298788a77ad6b1c9cbeb484a33e494e2352e61bc23c75ca3b1c7b76c4deb40ef
5
5
  SHA512:
6
- metadata.gz: 7fd02c87add0fdf9ac0b0a1b5ed6b79a278b258f8d40fc02c912e24d6995a4155bdea1a460b795c180e938a7b9f7af793f23a8ff3feec9cb15c4812101d22ce5
7
- data.tar.gz: 4788fa68c076ebb9901afd5fc6e24112939de491353096659b1151d841a37872d17f45b21b659287a976916d1b02a1342f2de536a835108a46559cfbd7af3ba2
6
+ metadata.gz: 780d46ca2607f8ba26fae821f958516ce71a2f74f14a39f3324231e49d8e2574426fbfd59517b0eb0d9059bfb06563417ac209dd92eb4ec7bf4872a870044616
7
+ data.tar.gz: 35cce2a67578153c350a8d493d95fdfb8f0fdc1b62bbe240dd0ffdd1a9daa509f49cc8fd617ac48d463afd53c97b8225b2a400d1bf27dd0c4f3070fc8a77ec89
data/CHANGELOG.md CHANGED
@@ -1,3 +1,39 @@
1
+ ## Rails 8.0.0.rc2 (October 30, 2024) ##
2
+
3
+ * Fix incorrect database.yml with `skip_solid`.
4
+
5
+ *Joé Dupuis*
6
+
7
+ * Set `Regexp.timeout` to `1`s by default to improve security over Regexp Denial-of-Service attacks.
8
+
9
+ *Rafael Mendonça França*
10
+
11
+
12
+ ## Rails 8.0.0.rc1 (October 19, 2024) ##
13
+
14
+ * Remove deprecated support to extend Rails console through `Rails::ConsoleMethods`.
15
+
16
+ *Rafael Mendonça França*
17
+
18
+ * Remove deprecated file `rails/console/helpers`.
19
+
20
+ *Rafael Mendonça França*
21
+
22
+ * Remove deprecated file `rails/console/app`.
23
+
24
+ *Rafael Mendonça França*
25
+
26
+ * Remove deprecated `config.read_encrypted_secrets`.
27
+
28
+ *Rafael Mendonça França*
29
+
30
+ * Add Kamal support for devcontainers
31
+
32
+ Previously generated devcontainer could not use docker and therefore Kamal.
33
+
34
+ *Joé Dupuis*
35
+
36
+
1
37
  ## Rails 8.0.0.beta1 (September 26, 2024) ##
2
38
 
3
39
  * Exit `rails g` with code 1 if generator could not be found.
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "fileutils"
4
- require "set"
5
4
  require "active_support/notifications"
6
5
  require "active_support/dependencies"
7
6
  require "active_support/descendants_tracker"
@@ -326,10 +326,6 @@ module Rails
326
326
 
327
327
  self.yjit = true
328
328
 
329
- if respond_to?(:active_job)
330
- active_job.enqueue_after_transaction_commit = :default
331
- end
332
-
333
329
  if respond_to?(:active_storage)
334
330
  active_storage.web_image_content_types = %w( image/png image/jpeg image/gif image/webp )
335
331
  end
@@ -348,6 +344,8 @@ module Rails
348
344
  if respond_to?(:action_dispatch)
349
345
  action_dispatch.strict_freshness = true
350
346
  end
347
+
348
+ Regexp.timeout ||= 1
351
349
  else
352
350
  raise "Unknown version #{target_version.to_s.inspect}"
353
351
  end
@@ -367,14 +365,6 @@ module Rails
367
365
  self.cache_classes = !value
368
366
  end
369
367
 
370
- def read_encrypted_secrets
371
- Rails.deprecator.warn("'config.read_encrypted_secrets' is deprecated and will be removed in Rails 8.0.")
372
- end
373
-
374
- def read_encrypted_secrets=(value)
375
- Rails.deprecator.warn("'config.read_encrypted_secrets=' is deprecated and will be removed in Rails 8.0.")
376
- end
377
-
378
368
  def encoding=(value)
379
369
  @encoding = value
380
370
  silence_warnings do
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "set"
4
3
  require "active_support/core_ext/string/inflections"
5
4
  require "active_support/core_ext/array/conversions"
6
5
  require "active_support/descendants_tracker"
data/lib/rails/command.rb CHANGED
@@ -23,12 +23,6 @@ module Rails
23
23
  super(message)
24
24
  end
25
25
 
26
- if !Exception.method_defined?(:detailed_message) # Ruby 3.2+
27
- def detailed_message(...)
28
- message
29
- end
30
- end
31
-
32
26
  if defined?(DidYouMean::Correctable) && defined?(DidYouMean::SpellChecker)
33
27
  include DidYouMean::Correctable
34
28
 
@@ -6,7 +6,6 @@ require "irb/command"
6
6
  module Rails
7
7
  class Console
8
8
  class RailsHelperBase < IRB::HelperMethod::Base
9
- include ConsoleMethods
10
9
  end
11
10
 
12
11
  class ControllerHelper < RailsHelperBase
@@ -51,9 +50,16 @@ module Rails
51
50
  end
52
51
  end
53
52
 
54
- class Reloader < IRB::Command::Base
55
- include ConsoleMethods
53
+ class ReloadHelper < RailsHelperBase
54
+ description "Reloads the Rails application."
55
+
56
+ def execute
57
+ puts "Reloading..."
58
+ Rails.application.reloader.reload!
59
+ end
60
+ end
56
61
 
62
+ class ReloadCommand < IRB::Command::Base
57
63
  category "Rails console"
58
64
  description "Reloads the Rails application."
59
65
 
@@ -67,7 +73,8 @@ module Rails
67
73
  IRB::HelperMethod.register(:controller, ControllerInstance)
68
74
  IRB::HelperMethod.register(:new_session, NewSession)
69
75
  IRB::HelperMethod.register(:app, AppInstance)
70
- IRB::Command.register(:reload!, Reloader)
76
+ IRB::HelperMethod.register(:reload!, ReloadHelper)
77
+ IRB::Command.register(:reload!, ReloadCommand)
71
78
 
72
79
  class IRBConsole
73
80
  def initialize(app)
@@ -110,10 +117,6 @@ module Rails
110
117
  end
111
118
  end
112
119
 
113
- # Because some users/libs use Rails::ConsoleMethods to extend Rails console,
114
- # we still include it for backward compatibility.
115
- IRB::ExtendCommandBundle.include ConsoleMethods
116
-
117
120
  # Respect user's choice of prompt mode.
118
121
  IRB.conf[:PROMPT_MODE] = :RAILS_PROMPT if IRB.conf[:PROMPT_MODE] == :DEFAULT
119
122
  IRB::Irb.new.run(IRB.conf)
@@ -27,6 +27,7 @@ module Rails
27
27
  redis: !!((defined?(ActionCable) && !defined?(SolidCable)) || (defined?(ActiveJob) && !defined?(SolidQueue))),
28
28
  system_test: File.exist?("test/application_system_test_case.rb"),
29
29
  node: File.exist?(".node-version"),
30
+ kamal: File.exist?("config/deploy.yml"),
30
31
  }
31
32
  end
32
33
 
@@ -1,23 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Rails
4
- module ConsoleMethods
5
- def self.include(_mod, ...)
6
- raise_deprecation_warning
7
- super
8
- end
9
-
10
- def self.method_added(_method_name)
11
- raise_deprecation_warning
12
- super
13
- end
14
-
15
- def self.raise_deprecation_warning
16
- Rails.deprecator.warn(<<~MSG, caller_locations(2..2))
17
- Extending Rails console through `Rails::ConsoleMethods` is deprecated and will be removed in Rails 8.0.
18
- Please directly use IRB's extension API to add new commands or helpers to the console.
19
- For more details, please visit: https://github.com/ruby/irb/blob/master/EXTEND_IRB.md
20
- MSG
21
- end
22
- end
23
- end
3
+ Rails.deprecator.warn(<<~MSG, caller_locations(0..1))
4
+ `rails/console/methods` has been deprecated and will be removed in Rails 8.1.
5
+ Please directly use IRB's extension API to add new commands or helpers to the console.
6
+ For more details, please visit: https://github.com/ruby/irb/blob/master/EXTEND_IRB.md
7
+ MSG
@@ -78,6 +78,11 @@ module Rails
78
78
  super
79
79
  end
80
80
 
81
+ def recognize_path_with_request(...)
82
+ Rails.application&.reload_routes_unless_loaded
83
+ super
84
+ end
85
+
81
86
  def routes
82
87
  Rails.application&.reload_routes_unless_loaded
83
88
  super
@@ -87,19 +92,19 @@ module Rails
87
92
  def method_missing_module
88
93
  @method_missing_module ||= Module.new do
89
94
  private
90
- def method_missing(method_name, *args, &block)
95
+ def method_missing(...)
91
96
  if Rails.application&.reload_routes_unless_loaded
92
- public_send(method_name, *args, &block)
97
+ public_send(...)
93
98
  else
94
- super(method_name, *args, &block)
99
+ super
95
100
  end
96
101
  end
97
102
 
98
- def respond_to_missing?(method_name, *args)
103
+ def respond_to_missing?(...)
99
104
  if Rails.application&.reload_routes_unless_loaded
100
- respond_to?(method_name, *args)
105
+ respond_to?(...)
101
106
  else
102
- super(method_name, *args)
107
+ super
103
108
  end
104
109
  end
105
110
  end
data/lib/rails/engine.rb CHANGED
@@ -245,7 +245,7 @@ module Rails
245
245
  # polymorphic_url(MyEngine::Article.new)
246
246
  # # => "articles_path" # not "my_engine_articles_path"
247
247
  #
248
- # form_for(MyEngine::Article.new) do
248
+ # form_with(model: MyEngine::Article.new) do
249
249
  # text_field :title # => <input type="text" name="article[title]" id="article_title" />
250
250
  # end
251
251
  #
@@ -294,7 +294,7 @@ module Rails
294
294
  # All you need to do is pass the helper as the first element in array with
295
295
  # attributes for URL:
296
296
  #
297
- # form_for([my_engine, @user])
297
+ # form_with(model: [my_engine, @user])
298
298
  #
299
299
  # This code will use <tt>my_engine.user_path(@user)</tt> to generate the proper route.
300
300
  #
@@ -452,7 +452,6 @@ module Rails
452
452
  # Load console and invoke the registered hooks.
453
453
  # Check Rails::Railtie.console for more info.
454
454
  def load_console(app = self)
455
- require "rails/console/methods"
456
455
  run_console_blocks(app)
457
456
  self
458
457
  end
@@ -10,7 +10,7 @@ module Rails
10
10
  MAJOR = 8
11
11
  MINOR = 0
12
12
  TINY = 0
13
- PRE = "beta1"
13
+ PRE = "rc2"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -659,10 +659,6 @@ module Rails
659
659
  !(options[:skip_bundle] || options[:pretend])
660
660
  end
661
661
 
662
- def bundler_windows_platforms
663
- Gem.rubygems_version >= Gem::Version.new("3.3.22") ? "windows" : "mswin mswin64 mingw x64_mingw"
664
- end
665
-
666
662
  def depends_on_system_test?
667
663
  !(options[:skip_system_test] || options[:skip_test] || options[:api])
668
664
  end
@@ -423,10 +423,6 @@ module Rails
423
423
  path = File.expand_path(File.join(base_name, generator_name), base_root)
424
424
  path if File.exist?(path)
425
425
  end
426
-
427
- def gem_ruby_version
428
- Gem::Version.new(Gem::VERSION) >= Gem::Version.new("3.3.13") ? Gem.ruby_version : RUBY_VERSION
429
- end
430
426
  end
431
427
  end
432
428
  end
@@ -6,9 +6,9 @@ module Erb # :nodoc:
6
6
  module Generators # :nodoc:
7
7
  class AuthenticationGenerator < Rails::Generators::Base # :nodoc:
8
8
  def create_files
9
- template "views/passwords/new.html.erb", File.join("app/views/passwords/new.html.erb")
10
- template "views/passwords/edit.html.erb", File.join("app/views/passwords/edit.html.erb")
11
- template "views/sessions/new.html.erb", File.join("app/views/sessions/new.html.erb")
9
+ template "app/views/passwords/new.html.erb"
10
+ template "app/views/passwords/edit.html.erb"
11
+ template "app/views/sessions/new.html.erb"
12
12
  end
13
13
  end
14
14
  end
@@ -1,4 +1,4 @@
1
- <h1>Update your password</h2>
1
+ <h1>Update your password</h1>
2
2
 
3
3
  <%%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
4
4
 
@@ -266,11 +266,13 @@ module Rails
266
266
  devcontainer_options = {
267
267
  database: options[:database],
268
268
  redis: options[:skip_solid] && !(options[:skip_action_cable] && options[:skip_active_job]),
269
+ kamal: !options[:skip_kamal],
269
270
  system_test: depends_on_system_test?,
270
271
  active_storage: !options[:skip_active_storage],
271
272
  dev: options[:dev],
272
273
  node: using_node?,
273
- app_name: app_name
274
+ app_name: app_name,
275
+ skip_solid: options[:skip_solid]
274
276
  }
275
277
 
276
278
  Rails::Generators::DevcontainerGenerator.new([], devcontainer_options).invoke_all
@@ -8,7 +8,7 @@
8
8
  # For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html
9
9
 
10
10
  # Make sure RUBY_VERSION matches the Ruby version in .ruby-version
11
- ARG RUBY_VERSION=<%= gem_ruby_version %>
11
+ ARG RUBY_VERSION=<%= Gem.ruby_version %>
12
12
  FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
13
13
 
14
14
  # Rails app lives here
@@ -10,7 +10,7 @@ source "https://rubygems.org"
10
10
  <% end -%>
11
11
 
12
12
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
13
- gem "tzinfo-data", platforms: %i[ <%= bundler_windows_platforms %> jruby ]
13
+ gem "tzinfo-data", platforms: %i[ windows jruby ]
14
14
  <% unless options.skip_solid? -%>
15
15
 
16
16
  <% if options.skip_action_cable? -%>
@@ -32,7 +32,7 @@ gem "bootsnap", require: false
32
32
  <% unless options.skip_kamal? -%>
33
33
 
34
34
  # Deploy this application anywhere as a Docker container [https://kamal-deploy.org]
35
- gem "kamal", ">= 2.0.0.rc2", require: false
35
+ gem "kamal", require: false
36
36
  <% end -%>
37
37
  <% unless options.skip_thruster? -%>
38
38
 
@@ -53,7 +53,7 @@ gem "thruster", require: false
53
53
 
54
54
  group :development, :test do
55
55
  # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
56
- gem "debug", platforms: %i[ mri <%= bundler_windows_platforms %> ], require: "debug/prelude"
56
+ gem "debug", platforms: %i[ mri windows ], require: "debug/prelude"
57
57
  <%- unless options.skip_brakeman? -%>
58
58
 
59
59
  # Static analysis for security vulnerabilities [https://brakemanscanner.org/]
@@ -19,10 +19,10 @@
19
19
 
20
20
  <%- style_link_target = options[:skip_asset_pipeline] ? "\"application\"" : ":app" -%>
21
21
  <%- if options[:skip_hotwire] || options[:skip_javascript] -%>
22
- <%%# Includes all stylesheet files in app/views/stylesheets %>
22
+ <%%# Includes all stylesheet files in app/assets/stylesheets %>
23
23
  <%%= stylesheet_link_tag <%= style_link_target %> %>
24
24
  <%- else -%>
25
- <%%# Includes all stylesheet files in app/views/stylesheets %>
25
+ <%%# Includes all stylesheet files in app/assets/stylesheets %>
26
26
  <%%= stylesheet_link_tag <%= style_link_target %>, "data-turbo-track": "reload" %>
27
27
  <%- end -%>
28
28
  </head>
@@ -1,7 +1,6 @@
1
1
  require "fileutils"
2
2
 
3
3
  APP_ROOT = File.expand_path("..", __dir__)
4
- APP_NAME = "<%= app_name.dasherize %>"
5
4
 
6
5
  def system!(*args)
7
6
  system(*args, exception: true)
@@ -13,8 +13,10 @@ servers:
13
13
  # - 192.168.0.1
14
14
  # cmd: bin/jobs
15
15
 
16
- # Enable SSL auto certification via Let's Encrypt (and allow for multiple apps on one server).
17
- # Set ssl: false if using something like Cloudflare to terminate SSL (but keep host!).
16
+ # Enable SSL auto certification via Let's Encrypt and allow for multiple apps on a single web server.
17
+ # Remove this section when using multiple web servers and ensure you terminate SSL at your load balancer.
18
+ #
19
+ # Note: If using Cloudflare, set encryption mode in SSL/TLS setting to "Full" to enable CF-to-app encryption.
18
20
  proxy:
19
21
  ssl: true
20
22
  host: app.example.com
@@ -56,6 +58,7 @@ env:
56
58
  # WEB_CONCURRENCY: 2
57
59
 
58
60
  # Match this to any external database server to configure Active Record correctly
61
+ # Use <%= app_name %>-db for a db accessory server on same machine via local kamal docker network.
59
62
  # DB_HOST: 192.168.0.2
60
63
 
61
64
  # Log everything from Rails
@@ -105,7 +108,8 @@ builder:
105
108
  # db:
106
109
  # image: mysql:8.0
107
110
  # host: 192.168.0.2
108
- # port: 3306
111
+ # # Change to 3306 to expose port to the world instead of just local network.
112
+ # port: "127.0.0.1:3306:3306"
109
113
  # env:
110
114
  # clear:
111
115
  # MYSQL_ROOT_HOST: '%'
@@ -23,3 +23,8 @@
23
23
  # If set to `false` both conditions need to be satisfied.
24
24
  #++
25
25
  # Rails.application.config.action_dispatch.strict_freshness = true
26
+
27
+ ###
28
+ # Set `Regexp.timeout` to `1`s by default to improve security over Regexp Denial-of-Service attacks.
29
+ #++
30
+ # Regexp.timeout = 1
@@ -126,7 +126,11 @@ jobs:
126
126
  DATABASE_URL: postgres://postgres:postgres@localhost:5432
127
127
  <%- end -%>
128
128
  # REDIS_URL: redis://localhost:6379/0
129
+ <%- if options[:api] -%>
130
+ run: bin/rails db:test:prepare test
131
+ <%- else -%>
129
132
  run: bin/rails db:test:prepare test test:system
133
+ <%- end -%>
130
134
 
131
135
  - name: Keep screenshots from failed system tests
132
136
  uses: actions/upload-artifact@v4
@@ -11,24 +11,26 @@ module Rails
11
11
  end
12
12
 
13
13
  def create_authentication_files
14
- template "models/session.rb", File.join("app/models/session.rb")
15
- template "models/user.rb", File.join("app/models/user.rb")
16
- template "models/current.rb", File.join("app/models/current.rb")
14
+ template "app/models/session.rb"
15
+ template "app/models/user.rb"
16
+ template "app/models/current.rb"
17
17
 
18
- template "controllers/sessions_controller.rb", File.join("app/controllers/sessions_controller.rb")
19
- template "controllers/concerns/authentication.rb", File.join("app/controllers/concerns/authentication.rb")
20
- template "controllers/passwords_controller.rb", File.join("app/controllers/passwords_controller.rb")
18
+ template "app/controllers/sessions_controller.rb"
19
+ template "app/controllers/concerns/authentication.rb"
20
+ template "app/controllers/passwords_controller.rb"
21
21
 
22
- template "mailers/passwords_mailer.rb", File.join("app/mailers/passwords_mailer.rb")
22
+ template "app/channels/application_cable/connection.rb" if defined?(ActionCable::Engine)
23
23
 
24
- template "views/passwords_mailer/reset.html.erb", File.join("app/views/passwords_mailer/reset.html.erb")
25
- template "views/passwords_mailer/reset.text.erb", File.join("app/views/passwords_mailer/reset.text.erb")
24
+ template "app/mailers/passwords_mailer.rb"
26
25
 
27
- template "test/mailers/previews/passwords_mailer_preview.rb", File.join("test/mailers/previews/passwords_mailer_preview.rb")
26
+ template "app/views/passwords_mailer/reset.html.erb"
27
+ template "app/views/passwords_mailer/reset.text.erb"
28
+
29
+ template "test/mailers/previews/passwords_mailer_preview.rb"
28
30
  end
29
31
 
30
32
  def configure_application_controller
31
- gsub_file "app/controllers/application_controller.rb", /(class ApplicationController < ActionController::Base)/, "\\1\n include Authentication"
33
+ inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " include Authentication\n"
32
34
  end
33
35
 
34
36
  def configure_authentication_routes
@@ -41,7 +43,7 @@ module Rails
41
43
  uncomment_lines "Gemfile", /gem "bcrypt"/
42
44
  Bundler.with_original_env { execute_command :bundle, "install --quiet" }
43
45
  else
44
- Bundler.with_original_env { execute_command :bundle, "add bcrypt --quiet" }
46
+ Bundler.with_original_env { execute_command :bundle, "add bcrypt", capture: true }
45
47
  end
46
48
  end
47
49
 
@@ -49,6 +51,8 @@ module Rails
49
51
  generate "migration CreateUsers email_address:string!:uniq password_digest:string! --force"
50
52
  generate "migration CreateSessions user:references ip_address:string user_agent:string --force"
51
53
  end
54
+
55
+ hook_for :test_framework
52
56
  end
53
57
  end
54
58
  end
@@ -0,0 +1,16 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ identified_by :current_user
4
+
5
+ def connect
6
+ set_current_user || reject_unauthorized_connection
7
+ end
8
+
9
+ private
10
+ def set_current_user
11
+ if session = Session.find_by(id: cookies.signed[:session_id])
12
+ self.current_user = session.user
13
+ end
14
+ end
15
+ end
16
+ end
@@ -14,7 +14,7 @@ module Authentication
14
14
 
15
15
  private
16
16
  def authenticated?
17
- Current.session.present?
17
+ resume_session
18
18
  end
19
19
 
20
20
  def require_authentication
@@ -23,7 +23,7 @@ module Authentication
23
23
 
24
24
 
25
25
  def resume_session
26
- Current.session = find_session_by_cookie
26
+ Current.session ||= find_session_by_cookie
27
27
  end
28
28
 
29
29
  def find_session_by_cookie
@@ -33,7 +33,7 @@ module Authentication
33
33
 
34
34
  def request_authentication
35
35
  session[:return_to_after_authenticating] = request.url
36
- redirect_to new_session_url
36
+ redirect_to new_session_path
37
37
  end
38
38
 
39
39
  def after_authentication_url
@@ -10,7 +10,7 @@ class PasswordsController < ApplicationController
10
10
  PasswordsMailer.reset(user).deliver_later
11
11
  end
12
12
 
13
- redirect_to new_session_url, notice: "Password reset instructions sent (if user with that email address exists)."
13
+ redirect_to new_session_path, notice: "Password reset instructions sent (if user with that email address exists)."
14
14
  end
15
15
 
16
16
  def edit
@@ -18,9 +18,9 @@ class PasswordsController < ApplicationController
18
18
 
19
19
  def update
20
20
  if @user.update(params.permit(:password, :password_confirmation))
21
- redirect_to new_session_url, notice: "Password has been reset."
21
+ redirect_to new_session_path, notice: "Password has been reset."
22
22
  else
23
- redirect_to edit_password_url(params[:token]), alert: "Passwords did not match."
23
+ redirect_to edit_password_path(params[:token]), alert: "Passwords did not match."
24
24
  end
25
25
  end
26
26
 
@@ -28,6 +28,6 @@ class PasswordsController < ApplicationController
28
28
  def set_user_by_token
29
29
  @user = User.find_by_password_reset_token!(params[:token])
30
30
  rescue ActiveSupport::MessageVerifier::InvalidSignature
31
- redirect_to new_password_url, alert: "Password reset link is invalid or has expired."
31
+ redirect_to new_password_path, alert: "Password reset link is invalid or has expired."
32
32
  end
33
33
  end
@@ -10,12 +10,12 @@ class SessionsController < ApplicationController
10
10
  start_new_session_for user
11
11
  redirect_to after_authentication_url
12
12
  else
13
- redirect_to new_session_url, alert: "Try another email address or password."
13
+ redirect_to new_session_path, alert: "Try another email address or password."
14
14
  end
15
15
  end
16
16
 
17
17
  def destroy
18
18
  terminate_session
19
- redirect_to new_session_url
19
+ redirect_to new_session_path
20
20
  end
21
21
  end
@@ -2,5 +2,5 @@ class User < ApplicationRecord
2
2
  has_secure_password
3
3
  has_many :sessions, dependent: :destroy
4
4
 
5
- normalizes :email_address, with: -> e { e.strip.downcase }
5
+ normalizes :email_address, with: ->(e) { e.strip.downcase }
6
6
  end
@@ -26,6 +26,12 @@ module Rails
26
26
  class_option :dev, type: :boolean, default: false,
27
27
  desc: "For applications pointing to a local Rails checkout"
28
28
 
29
+ class_option :kamal, type: :boolean, default: true,
30
+ desc: "Include configuration for Kamal"
31
+
32
+ class_option :skip_solid, type: :boolean, default: nil,
33
+ desc: "Skip Solid Cache & Queue setup"
34
+
29
35
  source_paths << File.expand_path(File.join(base_name, "app", "templates"), base_root)
30
36
 
31
37
  def create_devcontainer
@@ -80,6 +86,7 @@ module Rails
80
86
  @container_env["CAPYBARA_SERVER_PORT"] = "45678" if options[:system_test]
81
87
  @container_env["SELENIUM_HOST"] = "selenium" if options[:system_test]
82
88
  @container_env["REDIS_URL"] = "redis://redis:6379/1" if options[:redis]
89
+ @container_env["KAMAL_REGISTRY_PASSWORD"] = "$KAMAL_REGISTRY_PASSWORD" if options[:kamal]
83
90
  @container_env["DB_HOST"] = database.name if database.service
84
91
 
85
92
  @container_env
@@ -105,6 +112,7 @@ module Rails
105
112
 
106
113
  @features["ghcr.io/rails/devcontainer/features/activestorage"] = {} if options[:active_storage]
107
114
  @features["ghcr.io/devcontainers/features/node:1"] = {} if options[:node]
115
+ @features["ghcr.io/devcontainers/features/docker-outside-of-docker:1"] = {} if options[:kamal]
108
116
 
109
117
  @features.merge!(database.feature) if database.feature
110
118
 
@@ -1,3 +1,3 @@
1
1
  # Make sure RUBY_VERSION matches the Ruby version in .ruby-version
2
- ARG RUBY_VERSION=<%= gem_ruby_version %>
2
+ ARG RUBY_VERSION=<%= Gem.ruby_version %>
3
3
  FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION
@@ -19,5 +19,5 @@ gem "rubocop-rails-omakase", require: false
19
19
  <% end -%>
20
20
  <% if RUBY_PLATFORM.match?(/mingw|mswin|java/) -%>
21
21
 
22
- gem "tzinfo-data", platforms: %i[ <%= bundler_windows_platforms %> jruby ]
22
+ gem "tzinfo-data", platforms: %i[ windows jruby ]
23
23
  <% end -%>
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators/test_unit"
4
+
5
+ module TestUnit # :nodoc:
6
+ module Generators # :nodoc:
7
+ class AuthenticationGenerator < Rails::Generators::Base # :nodoc:
8
+ def create_user_test_files
9
+ template "test/fixtures/users.yml"
10
+ template "test/models/user_test.rb"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ <%% password_digest = BCrypt::Password.create("password") %>
2
+
3
+ one:
4
+ email_address: one@example.com
5
+ password_digest: <%%= password_digest %>
6
+
7
+ two:
8
+ email_address: two@example.com
9
+ password_digest: <%%= password_digest %>
@@ -0,0 +1,7 @@
1
+ require "test_helper"
2
+
3
+ class UserTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -125,6 +125,7 @@ module Rails
125
125
  def list_tests(patterns)
126
126
  tests = Rake::FileList[patterns.any? ? patterns : default_test_glob]
127
127
  tests.exclude(default_test_exclude_glob) if patterns.empty?
128
+ tests.exclude(%r{test/isolation/assets/node_modules})
128
129
  tests
129
130
  end
130
131
 
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: 8.0.0.beta1
4
+ version: 8.0.0.rc2
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: 2024-09-26 00:00:00.000000000 Z
11
+ date: 2024-10-30 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: 8.0.0.beta1
19
+ version: 8.0.0.rc2
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: 8.0.0.beta1
26
+ version: 8.0.0.rc2
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: 8.0.0.beta1
33
+ version: 8.0.0.rc2
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: 8.0.0.beta1
40
+ version: 8.0.0.rc2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rackup
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -120,14 +120,14 @@ dependencies:
120
120
  requirements:
121
121
  - - '='
122
122
  - !ruby/object:Gem::Version
123
- version: 8.0.0.beta1
123
+ version: 8.0.0.rc2
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - '='
129
129
  - !ruby/object:Gem::Version
130
- version: 8.0.0.beta1
130
+ version: 8.0.0.rc2
131
131
  description: 'Rails internals: application bootup, plugins, generators, and rake tasks.'
132
132
  email: david@loudthinking.com
133
133
  executables:
@@ -206,8 +206,6 @@ files:
206
206
  - lib/rails/commands/unused_routes/unused_routes_command.rb
207
207
  - lib/rails/commands/version/version_command.rb
208
208
  - lib/rails/configuration.rb
209
- - lib/rails/console/app.rb
210
- - lib/rails/console/helpers.rb
211
209
  - lib/rails/console/methods.rb
212
210
  - lib/rails/deprecator.rb
213
211
  - lib/rails/dev_caching.rb
@@ -228,9 +226,9 @@ files:
228
226
  - lib/rails/generators/database.rb
229
227
  - lib/rails/generators/erb.rb
230
228
  - lib/rails/generators/erb/authentication/authentication_generator.rb
231
- - lib/rails/generators/erb/authentication/templates/views/passwords/edit.html.erb
232
- - lib/rails/generators/erb/authentication/templates/views/passwords/new.html.erb
233
- - lib/rails/generators/erb/authentication/templates/views/sessions/new.html.erb
229
+ - lib/rails/generators/erb/authentication/templates/app/views/passwords/edit.html.erb
230
+ - lib/rails/generators/erb/authentication/templates/app/views/passwords/new.html.erb
231
+ - lib/rails/generators/erb/authentication/templates/app/views/sessions/new.html.erb
234
232
  - lib/rails/generators/erb/controller/controller_generator.rb
235
233
  - lib/rails/generators/erb/controller/templates/view.html.erb.tt
236
234
  - lib/rails/generators/erb/mailer/mailer_generator.rb
@@ -320,16 +318,17 @@ files:
320
318
  - lib/rails/generators/rails/application_record/application_record_generator.rb
321
319
  - lib/rails/generators/rails/authentication/USAGE
322
320
  - lib/rails/generators/rails/authentication/authentication_generator.rb
323
- - lib/rails/generators/rails/authentication/templates/controllers/concerns/authentication.rb
324
- - lib/rails/generators/rails/authentication/templates/controllers/passwords_controller.rb
325
- - lib/rails/generators/rails/authentication/templates/controllers/sessions_controller.rb
326
- - lib/rails/generators/rails/authentication/templates/mailers/passwords_mailer.rb
327
- - lib/rails/generators/rails/authentication/templates/models/current.rb
328
- - lib/rails/generators/rails/authentication/templates/models/session.rb
329
- - lib/rails/generators/rails/authentication/templates/models/user.rb
330
- - lib/rails/generators/rails/authentication/templates/test/mailers/previews/passwords_mailer_preview.rb
331
- - lib/rails/generators/rails/authentication/templates/views/passwords_mailer/reset.html.erb
332
- - lib/rails/generators/rails/authentication/templates/views/passwords_mailer/reset.text.erb
321
+ - lib/rails/generators/rails/authentication/templates/app/channels/application_cable/connection.rb.tt
322
+ - lib/rails/generators/rails/authentication/templates/app/controllers/concerns/authentication.rb.tt
323
+ - lib/rails/generators/rails/authentication/templates/app/controllers/passwords_controller.rb.tt
324
+ - lib/rails/generators/rails/authentication/templates/app/controllers/sessions_controller.rb.tt
325
+ - lib/rails/generators/rails/authentication/templates/app/mailers/passwords_mailer.rb.tt
326
+ - lib/rails/generators/rails/authentication/templates/app/models/current.rb.tt
327
+ - lib/rails/generators/rails/authentication/templates/app/models/session.rb.tt
328
+ - lib/rails/generators/rails/authentication/templates/app/models/user.rb.tt
329
+ - lib/rails/generators/rails/authentication/templates/app/views/passwords_mailer/reset.html.erb.tt
330
+ - lib/rails/generators/rails/authentication/templates/app/views/passwords_mailer/reset.text.erb.tt
331
+ - lib/rails/generators/rails/authentication/templates/test/mailers/previews/passwords_mailer_preview.rb.tt
333
332
  - lib/rails/generators/rails/benchmark/USAGE
334
333
  - lib/rails/generators/rails/benchmark/benchmark_generator.rb
335
334
  - lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt
@@ -412,6 +411,9 @@ files:
412
411
  - lib/rails/generators/resource_helpers.rb
413
412
  - lib/rails/generators/test_case.rb
414
413
  - lib/rails/generators/test_unit.rb
414
+ - lib/rails/generators/test_unit/authentication/authentication_generator.rb
415
+ - lib/rails/generators/test_unit/authentication/templates/test/fixtures/users.yml.tt
416
+ - lib/rails/generators/test_unit/authentication/templates/test/models/user_test.rb.tt
415
417
  - lib/rails/generators/test_unit/controller/controller_generator.rb
416
418
  - lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt
417
419
  - lib/rails/generators/test_unit/generator/generator_generator.rb
@@ -489,10 +491,10 @@ licenses:
489
491
  - MIT
490
492
  metadata:
491
493
  bug_tracker_uri: https://github.com/rails/rails/issues
492
- changelog_uri: https://github.com/rails/rails/blob/v8.0.0.beta1/railties/CHANGELOG.md
493
- documentation_uri: https://api.rubyonrails.org/v8.0.0.beta1/
494
+ changelog_uri: https://github.com/rails/rails/blob/v8.0.0.rc2/railties/CHANGELOG.md
495
+ documentation_uri: https://api.rubyonrails.org/v8.0.0.rc2/
494
496
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
495
- source_code_uri: https://github.com/rails/rails/tree/v8.0.0.beta1/railties
497
+ source_code_uri: https://github.com/rails/rails/tree/v8.0.0.rc2/railties
496
498
  rubygems_mfa_required: 'true'
497
499
  post_install_message:
498
500
  rdoc_options:
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Rails.deprecator.warn(<<~MSG, caller_locations(0..1))
4
- `rails/console/app` has been deprecated and will be removed in Rails 8.0.
5
- Please require `rails/console/methods` instead.
6
- MSG
7
-
8
- require "rails/console/methods"
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Rails.deprecator.warn(<<~MSG, caller_locations(0..1))
4
- `rails/console/helpers` has been deprecated and will be removed in Rails 8.0.
5
- Please require `rails/console/methods` instead.
6
- MSG
7
-
8
- require "rails/console/methods"