Skip to content

Commit 4786b07

Browse files
authored
Merge pull request #1693 from coderdojo-japan/upgrade-to-rails-8-0
Upgrade Ruby on Rails: 7.2 -> 8.0
2 parents abd35d1 + 3eb9b87 commit 4786b07

21 files changed

+733
-427
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ gem 'bootsnap'
55
gem 'pg'
66
gem 'puma'
77
gem 'puma_worker_killer'
8-
gem 'rails', '~> 7.2.0'
8+
gem 'rails', '~> 8.0.0'
99

1010
gem 'jbuilder'
1111
gem 'jquery-rails'

Gemfile.lock

Lines changed: 57 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,65 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actioncable (7.2.2.1)
5-
actionpack (= 7.2.2.1)
6-
activesupport (= 7.2.2.1)
4+
actioncable (8.0.2)
5+
actionpack (= 8.0.2)
6+
activesupport (= 8.0.2)
77
nio4r (~> 2.0)
88
websocket-driver (>= 0.6.1)
99
zeitwerk (~> 2.6)
10-
actionmailbox (7.2.2.1)
11-
actionpack (= 7.2.2.1)
12-
activejob (= 7.2.2.1)
13-
activerecord (= 7.2.2.1)
14-
activestorage (= 7.2.2.1)
15-
activesupport (= 7.2.2.1)
10+
actionmailbox (8.0.2)
11+
actionpack (= 8.0.2)
12+
activejob (= 8.0.2)
13+
activerecord (= 8.0.2)
14+
activestorage (= 8.0.2)
15+
activesupport (= 8.0.2)
1616
mail (>= 2.8.0)
17-
actionmailer (7.2.2.1)
18-
actionpack (= 7.2.2.1)
19-
actionview (= 7.2.2.1)
20-
activejob (= 7.2.2.1)
21-
activesupport (= 7.2.2.1)
17+
actionmailer (8.0.2)
18+
actionpack (= 8.0.2)
19+
actionview (= 8.0.2)
20+
activejob (= 8.0.2)
21+
activesupport (= 8.0.2)
2222
mail (>= 2.8.0)
2323
rails-dom-testing (~> 2.2)
24-
actionpack (7.2.2.1)
25-
actionview (= 7.2.2.1)
26-
activesupport (= 7.2.2.1)
24+
actionpack (8.0.2)
25+
actionview (= 8.0.2)
26+
activesupport (= 8.0.2)
2727
nokogiri (>= 1.8.5)
28-
racc
29-
rack (>= 2.2.4, < 3.2)
28+
rack (>= 2.2.4)
3029
rack-session (>= 1.0.1)
3130
rack-test (>= 0.6.3)
3231
rails-dom-testing (~> 2.2)
3332
rails-html-sanitizer (~> 1.6)
3433
useragent (~> 0.16)
35-
actiontext (7.2.2.1)
36-
actionpack (= 7.2.2.1)
37-
activerecord (= 7.2.2.1)
38-
activestorage (= 7.2.2.1)
39-
activesupport (= 7.2.2.1)
34+
actiontext (8.0.2)
35+
actionpack (= 8.0.2)
36+
activerecord (= 8.0.2)
37+
activestorage (= 8.0.2)
38+
activesupport (= 8.0.2)
4039
globalid (>= 0.6.0)
4140
nokogiri (>= 1.8.5)
42-
actionview (7.2.2.1)
43-
activesupport (= 7.2.2.1)
41+
actionview (8.0.2)
42+
activesupport (= 8.0.2)
4443
builder (~> 3.1)
4544
erubi (~> 1.11)
4645
rails-dom-testing (~> 2.2)
4746
rails-html-sanitizer (~> 1.6)
48-
activejob (7.2.2.1)
49-
activesupport (= 7.2.2.1)
47+
activejob (8.0.2)
48+
activesupport (= 8.0.2)
5049
globalid (>= 0.3.6)
51-
activemodel (7.2.2.1)
52-
activesupport (= 7.2.2.1)
53-
activerecord (7.2.2.1)
54-
activemodel (= 7.2.2.1)
55-
activesupport (= 7.2.2.1)
50+
activemodel (8.0.2)
51+
activesupport (= 8.0.2)
52+
activerecord (8.0.2)
53+
activemodel (= 8.0.2)
54+
activesupport (= 8.0.2)
5655
timeout (>= 0.4.0)
57-
activestorage (7.2.2.1)
58-
actionpack (= 7.2.2.1)
59-
activejob (= 7.2.2.1)
60-
activerecord (= 7.2.2.1)
61-
activesupport (= 7.2.2.1)
56+
activestorage (8.0.2)
57+
actionpack (= 8.0.2)
58+
activejob (= 8.0.2)
59+
activerecord (= 8.0.2)
60+
activesupport (= 8.0.2)
6261
marcel (~> 1.0)
63-
activesupport (7.2.2.1)
62+
activesupport (8.0.2)
6463
base64
6564
benchmark (>= 0.3)
6665
bigdecimal
@@ -72,6 +71,7 @@ GEM
7271
minitest (>= 5.1)
7372
securerandom (>= 0.3)
7473
tzinfo (~> 2.0, >= 2.0.5)
74+
uri (>= 0.13.1)
7575
addressable (2.8.7)
7676
public_suffix (>= 2.0.2, < 7.0)
7777
airbrake (13.0.5)
@@ -342,20 +342,20 @@ GEM
342342
woothee (>= 1.0.0)
343343
rackup (2.2.1)
344344
rack (>= 3)
345-
rails (7.2.2.1)
346-
actioncable (= 7.2.2.1)
347-
actionmailbox (= 7.2.2.1)
348-
actionmailer (= 7.2.2.1)
349-
actionpack (= 7.2.2.1)
350-
actiontext (= 7.2.2.1)
351-
actionview (= 7.2.2.1)
352-
activejob (= 7.2.2.1)
353-
activemodel (= 7.2.2.1)
354-
activerecord (= 7.2.2.1)
355-
activestorage (= 7.2.2.1)
356-
activesupport (= 7.2.2.1)
345+
rails (8.0.2)
346+
actioncable (= 8.0.2)
347+
actionmailbox (= 8.0.2)
348+
actionmailer (= 8.0.2)
349+
actionpack (= 8.0.2)
350+
actiontext (= 8.0.2)
351+
actionview (= 8.0.2)
352+
activejob (= 8.0.2)
353+
activemodel (= 8.0.2)
354+
activerecord (= 8.0.2)
355+
activestorage (= 8.0.2)
356+
activesupport (= 8.0.2)
357357
bundler (>= 1.15.0)
358-
railties (= 7.2.2.1)
358+
railties (= 8.0.2)
359359
rails-controller-testing (1.0.5)
360360
actionpack (>= 5.0.1.rc1)
361361
actionview (>= 5.0.1.rc1)
@@ -367,9 +367,9 @@ GEM
367367
rails-html-sanitizer (1.6.2)
368368
loofah (~> 2.21)
369369
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
370-
railties (7.2.2.1)
371-
actionpack (= 7.2.2.1)
372-
activesupport (= 7.2.2.1)
370+
railties (8.0.2)
371+
actionpack (= 8.0.2)
372+
activesupport (= 8.0.2)
373373
irb (~> 1.13)
374374
rackup (>= 1.0.0)
375375
rake (>= 12.2)
@@ -506,6 +506,7 @@ GEM
506506
unicode-display_width (3.1.4)
507507
unicode-emoji (~> 4.0, >= 4.0.4)
508508
unicode-emoji (4.0.4)
509+
uri (1.0.3)
509510
useragent (0.16.11)
510511
web-console (4.2.1)
511512
actionview (>= 6.0.0)
@@ -567,7 +568,7 @@ DEPENDENCIES
567568
rack-host-redirect
568569
rack-mini-profiler
569570
rack-user_agent
570-
rails (~> 7.2.0)
571+
rails (~> 8.0.0)
571572
rails-controller-testing
572573
rails-html-sanitizer
573574
rake

bin/dev

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env ruby
2+
exec "./bin/rails", "server", *ARGV

bin/setup

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
require "fileutils"
33

44
APP_ROOT = File.expand_path("..", __dir__)
5-
APP_NAME = "coderdojo-jp"
65

76
def system!(*args)
87
system(*args, exception: true)
@@ -14,7 +13,6 @@ FileUtils.chdir APP_ROOT do
1413
# Add necessary setup steps to this file.
1514

1615
puts "== Installing dependencies =="
17-
system! "gem install bundler --conservative"
1816
system("bundle check") || system!("bundle install")
1917

2018
# puts "\n== Copying sample files =="
@@ -56,10 +54,9 @@ FileUtils.chdir APP_ROOT do
5654
puts "\n== Removing old logs and tempfiles =="
5755
system! "bin/rails log:clear tmp:clear"
5856

59-
puts "\n== Restarting application server =="
60-
system! "bin/rails restart"
61-
62-
# puts "\n== Configuring puma-dev =="
63-
# system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
64-
# system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
57+
unless ARGV.include?("--skip-server")
58+
puts "\n== Starting development server =="
59+
STDOUT.flush # flush the output before exec(2) so that it displays
60+
exec "bin/dev"
61+
end
6562
end

config/application.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,13 @@ class Application < Rails::Application
3232

3333
# Fixture paths
3434
config.fixture_paths = [Rails.root.join('spec/fixtures')]
35+
36+
# TODO: The following config should be switched to its default value `true`, but not urgent.
37+
# Rails 5.0: Require `belongs_to` associations by default. Previous versions had false.
38+
# https://railsguides.jp/configuring.html#config-active-record-belongs-to-required-by-default
39+
config.active_record.belongs_to_required_by_default = false
40+
41+
# Rails 8.0: `to_time` will always preserve the full timezone in Rails 8.1.
42+
config.active_support.to_time_preserves_timezone = :zone
3543
end
3644
end

config/environments/development.rb

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
Rails.application.configure do
44
# Settings specified here will take precedence over those in config/application.rb.
55

6-
# In the development environment your application's code is reloaded any time
7-
# it changes. This slows down response time but is perfect for development
8-
# since you don't have to restart the web server when you make code changes.
6+
# Make code changes take effect immediately without server restart.
97
config.enable_reloading = true
108

119
# Do not eager load code on boot.
@@ -17,53 +15,47 @@
1715
# Enable server timing.
1816
config.server_timing = true
1917

20-
# Enable/disable caching. By default caching is disabled.
21-
# Run rails dev:cache to toggle caching.
18+
# Enable/disable Action Controller caching. By default Action Controller caching is disabled.
19+
# Run rails dev:cache to toggle Action Controller caching.
2220
if Rails.root.join("tmp/caching-dev.txt").exist?
2321
config.action_controller.perform_caching = true
2422
config.action_controller.enable_fragment_cache_logging = true
25-
26-
config.cache_store = :memory_store
27-
config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" }
23+
config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
2824
else
2925
config.action_controller.perform_caching = false
30-
31-
config.cache_store = :null_store
3226
end
3327

28+
# Change to :null_store to avoid any caching.
29+
config.cache_store = :memory_store
30+
3431
# Store uploaded files on the local file system (see config/storage.yml for options).
3532
config.active_storage.service = :local
3633

3734
# Don't care if the mailer can't send.
3835
config.action_mailer.raise_delivery_errors = false
3936

40-
# Disable caching for Action Mailer templates even if Action Controller
41-
# caching is enabled.
37+
# Make template changes take effect immediately.
4238
config.action_mailer.perform_caching = false
39+
40+
# Set localhost to be used by links generated in mailer templates.
4341
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
4442
config.action_mailer.delivery_method = :letter_opener_web
4543

4644
# Print deprecation notices to the Rails logger.
4745
config.active_support.deprecation = :log
4846

49-
# Raise exceptions for disallowed deprecations.
50-
config.active_support.disallowed_deprecation = :raise
51-
52-
# Tell Active Support which deprecation messages to disallow.
53-
config.active_support.disallowed_deprecation_warnings = []
54-
5547
# Raise an error on page load if there are pending migrations.
5648
config.active_record.migration_error = :page_load
5749

5850
# Highlight code that triggered database queries in logs.
5951
config.active_record.verbose_query_logs = true
6052

53+
# Append comments with runtime information tags to SQL queries in logs.
54+
config.active_record.query_log_tags_enabled = true
55+
6156
# Highlight code that enqueued background job in logs.
6257
config.active_job.verbose_enqueue_logs = true
6358

64-
# Suppress logger output for asset requests.
65-
config.assets.quiet = true
66-
6759
# Raises error for missing translations.
6860
# config.i18n.raise_on_missing_translations = true
6961

0 commit comments

Comments
 (0)