Skip to content

Upgrade Ruby on Rails: 7.1 -> 7.2 #1692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1f7bc30
Pin 'rails' gem to '~> 7.2.0'
yasulab May 23, 2025
4cd82de
Exec: bundle update rails
yasulab May 23, 2025
7ed5fff
Fix 'enum' keyword argument for Rails 8.0
yasulab May 23, 2025
543fd2f
Update for Rails 7.2: bin/setup
yasulab May 23, 2025
a21174c
Update for Rails 7.2: config/application.rb
yasulab May 23, 2025
f54b7a2
Update for Rails 7.2: config/environments/development.rb
yasulab May 23, 2025
62f9535
Update for Rails 7.2: config/environments/production.rb
yasulab May 23, 2025
36156e7
Update for Rails 7.2: config/environments/test.rb
yasulab May 23, 2025
bc93653
Update for Rails 7.2: config/initializers/assets.rb
yasulab May 23, 2025
039fcd3
Update for Rails 7.2: config/initializers/filter_parameter_logging.rb
yasulab May 23, 2025
bbb0382
Add Rails 7.2 instructions: config/initializers/new_framework_default…
yasulab May 23, 2025
d05de2b
Update for Rails 7.2: config/puma.rb (with Heroku-specific setttings)
yasulab May 23, 2025
09670f0
Add default error pages in case:
yasulab May 23, 2025
90606b5
Update for Rails 7.2: public/robots.txt (Cosmetic Change)
yasulab May 23, 2025
67bcf71
Add default RuboCop in Rails 7.2 (But not being used for now in this …
yasulab May 23, 2025
abd5419
Fix error to refer to 'pf_host' variable in development
yasulab May 23, 2025
e50ae72
Fix error to refer to 'pf_domain' variable in development
yasulab May 23, 2025
e848661
Use Time.zone.today instead of Date.today that requires 'date' gem
yasulab May 23, 2025
908565f
Use 'active_support/time' to fetch current time in bin/setup
yasulab May 23, 2025
8b2cbbb
Load only static_yaml in 'bin/setup' for better on-boarding experiences
yasulab May 23, 2025
0453daf
bin/setup に必須ではないコマンドはコメントアウトして1箇所にまとめた
yasulab May 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ gem 'bootsnap'
gem 'pg'
gem 'puma'
gem 'puma_worker_killer'
gem 'rails', '~> 7.1.5'
gem 'rails', '~> 7.2.0'

gem 'jbuilder'
gem 'jquery-rails'
Expand Down
129 changes: 62 additions & 67 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,83 +1,77 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (7.1.5.1)
actionpack (= 7.1.5.1)
activesupport (= 7.1.5.1)
actioncable (7.2.2.1)
actionpack (= 7.2.2.1)
activesupport (= 7.2.2.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (7.1.5.1)
actionpack (= 7.1.5.1)
activejob (= 7.1.5.1)
activerecord (= 7.1.5.1)
activestorage (= 7.1.5.1)
activesupport (= 7.1.5.1)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.1.5.1)
actionpack (= 7.1.5.1)
actionview (= 7.1.5.1)
activejob (= 7.1.5.1)
activesupport (= 7.1.5.1)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
actionmailbox (7.2.2.1)
actionpack (= 7.2.2.1)
activejob (= 7.2.2.1)
activerecord (= 7.2.2.1)
activestorage (= 7.2.2.1)
activesupport (= 7.2.2.1)
mail (>= 2.8.0)
actionmailer (7.2.2.1)
actionpack (= 7.2.2.1)
actionview (= 7.2.2.1)
activejob (= 7.2.2.1)
activesupport (= 7.2.2.1)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (7.1.5.1)
actionview (= 7.1.5.1)
activesupport (= 7.1.5.1)
actionpack (7.2.2.1)
actionview (= 7.2.2.1)
activesupport (= 7.2.2.1)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4)
rack (>= 2.2.4, < 3.2)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
actiontext (7.1.5.1)
actionpack (= 7.1.5.1)
activerecord (= 7.1.5.1)
activestorage (= 7.1.5.1)
activesupport (= 7.1.5.1)
useragent (~> 0.16)
actiontext (7.2.2.1)
actionpack (= 7.2.2.1)
activerecord (= 7.2.2.1)
activestorage (= 7.2.2.1)
activesupport (= 7.2.2.1)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.1.5.1)
activesupport (= 7.1.5.1)
actionview (7.2.2.1)
activesupport (= 7.2.2.1)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (7.1.5.1)
activesupport (= 7.1.5.1)
activejob (7.2.2.1)
activesupport (= 7.2.2.1)
globalid (>= 0.3.6)
activemodel (7.1.5.1)
activesupport (= 7.1.5.1)
activerecord (7.1.5.1)
activemodel (= 7.1.5.1)
activesupport (= 7.1.5.1)
activemodel (7.2.2.1)
activesupport (= 7.2.2.1)
activerecord (7.2.2.1)
activemodel (= 7.2.2.1)
activesupport (= 7.2.2.1)
timeout (>= 0.4.0)
activestorage (7.1.5.1)
actionpack (= 7.1.5.1)
activejob (= 7.1.5.1)
activerecord (= 7.1.5.1)
activesupport (= 7.1.5.1)
activestorage (7.2.2.1)
actionpack (= 7.2.2.1)
activejob (= 7.2.2.1)
activerecord (= 7.2.2.1)
activesupport (= 7.2.2.1)
marcel (~> 1.0)
activesupport (7.1.5.1)
activesupport (7.2.2.1)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
mutex_m
securerandom (>= 0.3)
tzinfo (~> 2.0)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
airbrake (13.0.5)
Expand Down Expand Up @@ -348,20 +342,20 @@ GEM
woothee (>= 1.0.0)
rackup (2.2.1)
rack (>= 3)
rails (7.1.5.1)
actioncable (= 7.1.5.1)
actionmailbox (= 7.1.5.1)
actionmailer (= 7.1.5.1)
actionpack (= 7.1.5.1)
actiontext (= 7.1.5.1)
actionview (= 7.1.5.1)
activejob (= 7.1.5.1)
activemodel (= 7.1.5.1)
activerecord (= 7.1.5.1)
activestorage (= 7.1.5.1)
activesupport (= 7.1.5.1)
rails (7.2.2.1)
actioncable (= 7.2.2.1)
actionmailbox (= 7.2.2.1)
actionmailer (= 7.2.2.1)
actionpack (= 7.2.2.1)
actiontext (= 7.2.2.1)
actionview (= 7.2.2.1)
activejob (= 7.2.2.1)
activemodel (= 7.2.2.1)
activerecord (= 7.2.2.1)
activestorage (= 7.2.2.1)
activesupport (= 7.2.2.1)
bundler (>= 1.15.0)
railties (= 7.1.5.1)
railties (= 7.2.2.1)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
Expand All @@ -373,10 +367,10 @@ GEM
rails-html-sanitizer (1.6.2)
loofah (~> 2.21)
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)
railties (7.1.5.1)
actionpack (= 7.1.5.1)
activesupport (= 7.1.5.1)
irb
railties (7.2.2.1)
actionpack (= 7.2.2.1)
activesupport (= 7.2.2.1)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
Expand Down Expand Up @@ -512,6 +506,7 @@ GEM
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
useragent (0.16.11)
web-console (4.2.1)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand Down Expand Up @@ -572,7 +567,7 @@ DEPENDENCIES
rack-host-redirect
rack-mini-profiler
rack-user_agent
rails (~> 7.1.5)
rails (~> 7.2.0)
rails-controller-testing
rails-html-sanitizer
rake
Expand Down
2 changes: 1 addition & 1 deletion app/models/dojo_event_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class DojoEventService < ApplicationRecord
belongs_to :dojo
has_many :upcoming_events, dependent: :destroy

enum name: EXTERNAL_SERVICES + INTERNAL_SERVICES
enum :name, EXTERNAL_SERVICES + INTERNAL_SERVICES

validates :name, presence: true
validates :group_id, uniqueness: { scope: :name }, unless: Proc.new { |a| a.group_id.blank? }
Expand Down
8 changes: 8 additions & 0 deletions bin/rubocop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"

# explicit rubocop config increases performance slightly while avoiding config confusion.
ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))

load Gem.bin_path("rubocop", "rubocop")
81 changes: 39 additions & 42 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -1,68 +1,65 @@
#!/usr/bin/env ruby
require "fileutils"
require 'date'

# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
APP_ROOT = File.expand_path("..", __dir__)
APP_NAME = "coderdojo-jp"

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

def doorkeeper_message
<<~MESSAGE

環境変数 DOORKEEPER_API_TOKEN が設定されていないため、
Doorkeeper API を使ったイベント情報の取得をスキップします。

Doorkeeper のイベントを取得するためには、
下記ページから Doorkeeper API Token を取得し、
環境変数 DOORKEEPER_API_TOKEN に設定してください。
https://manage.doorkeeper.jp/user/oauth/applications

環境変数設定後に、bin/setup を再実行してください!

MESSAGE
system(*args, exception: true)
end

FileUtils.chdir APP_ROOT do
# This script is a way to set up or update your development environment automatically.
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
# Add necessary setup steps to this file.

puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "== Installing dependencies =="
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")

# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml"
# unless File.exist?("config/database.yml")
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
# end

puts "\n== Preparing database =="
system! 'bin/rails db:prepare'
system! "bin/rails db:prepare"

puts "\n== Upserting application data =="
system! 'bin/rails dojos:update_db_by_yaml'
system! 'bin/rails dojo_event_services:upsert'

today = Date.today
from = (today - 90).strftime('%Y%m')
to = today.prev_month.strftime('%Y%m')

if ENV['DOORKEEPER_API_TOKEN']
system! "bin/rails statistics:aggregation[#{from},#{to}]"
system! 'bin/rails upcoming_events:aggregation'
else
puts doorkeeper_message
system! "bin/rails statistics:aggregation[#{from},#{to},connpass]"
system! "bin/rails statistics:aggregation[#{from},#{to},facebook]"
system! 'bin/rails upcoming_events:aggregation[connpass]'
end
system! "bin/rails statistics:aggregation[-,-,static_yaml]"

# TODO: This would be better to move outside bin/setup. 'static_yaml' is enough fine.
#
#require "active_support/time"
#today = Time.now.in_time_zone('Tokyo').to_date
#from = (today - 90).strftime('%Y%m')
#to = today.prev_month.strftime('%Y%m')
#if ENV['DOORKEEPER_API_TOKEN'] && ENV['FIXIE_URL']
# system! "bin/rails statistics:aggregation[#{from},#{to}]"
# system! 'bin/rails upcoming_events:aggregation'
#elsif ENV['DOORKEEPER_API_TOKEN']
# system! "bin/rails statistics:aggregation[#{from},#{to},connpass]"
# system! "bin/rails statistics:aggregation[#{from},#{to},facebook]"
# system! 'bin/rails upcoming_events:aggregation[connpass]'
#else
# puts <<~MESSAGE
# 環境変数 DOORKEEPER_API_TOKEN と FIXIE_URL が設定されていないため、
# Doorkeeper API や connpass API を使ったイベント情報の取得をスキップします。
#
# なお API 経由でイベント情報を取得しなくても、rails server は実行可能です。
# もし API 経由でイベント情報を取得したい場合は開発チームにご連絡ください。
# MESSAGE
#end

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
system! "bin/rails log:clear tmp:clear"

puts "\n== Restarting application server =="
system! 'bin/rails restart'
system! "bin/rails restart"

# puts "\n== Configuring puma-dev =="
# system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
# system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
end
8 changes: 2 additions & 6 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@
module CoderdojoJp
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
# Each version's default can be checked at `config/initializers/new_framework_defaults_*.rb`
config.load_defaults 7.1

# パフォーマンス最適化: autoloadパスを$LOAD_PATHに追加しない
config.add_autoload_paths_to_load_path = false
config.load_defaults 7.2

# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: %w(assets tasks))
config.autoload_lib(ignore: %w[assets tasks])

# Configuration for the application, engines, and railties goes here.
#
Expand Down
Loading