-
Notifications
You must be signed in to change notification settings - Fork 75
実験 rails7.2 #9303
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
base: main
Are you sure you want to change the base?
実験 rails7.2 #9303
Conversation
- Gemfile: Rails 6.1.7.10 → 7.0.10に更新 - rails-i18nを7.0.0に更新 - net-smtp のTODOコメントを削除 - bundle updateでRails 7.0.10をインストール
- config/application.rb: load_defaultsを7.0に更新 - config/environments/development.rb: config.assetsをコメントアウト - config/environments/production.rb: config.assetsをコメントアウト - config/initializers/assets.rb: Sprockets設定を全てコメントアウト Rails 7ではSprocketsがデフォルトでは含まれないため、 sprockets-rails gemを追加しない限りconfig.assetsは使用できない。
テスト環境でWebpackerアセットが正しく読み込まれるよう、 config/webpacker.ymlのpublic_output_pathをpacks-testに設定。 これによりシステムテストでのアセット読み込みエラーが解消された。
Rails 7ではActiveStorageサービスのroot=セッターが存在しないため、 インスタンス変数を直接操作するように変更。 - parallelize_setupで元のrootを保存してからインスタンス変数を設定 - Minitest.after_runでもインスタンス変数から値を取得 - これによりparallel testingで各ワーカーが独自のストレージパスを使用可能
Sprocketsの`image-url()`ヘルパーをWebpackerの`~`パスに変更。
Rails 7 + Webpacker環境では、Sassファイル内でSprocketsヘルパーが
使えないため、Webpackerの機能を使って画像を参照する。
- image-url('background/people.png') → url('~background/people.png')
- これによりCIでの"No route matches [GET] /packs/media/..."エラーを解消
Node 20のOpenSSL 3.0でWebpackerをコンパイルする際のエラーを解決。 - bin/webpackとbin/webpack-dev-serverにNODE_OPTIONS環境変数を設定 - --openssl-legacy-providerを使用してレガシー暗号アルゴリズムをサポート - これによりCI環境でのWebpackerコンパイルエラーを解消 - "/packs/js/..." のルーティングエラーも解決 参考: webpack/webpack#14532
test環境でpublic_output_path: packs-testを設定していたため、 ファイルはpublic/packs-test/に出力されるがアプリケーションは /packs/から読み込もうとしてルーティングエラーが発生していた。 デフォルトのpacksディレクトリを使用するように修正。
app/assets/imagesからapp/javascript/imagesに画像を移動し、 Webpackerで直接管理するように変更。これによりCI環境でも 確実に画像がコンパイルされるようになる。 変更内容: - 画像をapp/javascript/images/background/に配置 - lp.jsのimportパスを更新 - Sassのurl()を~images/background/people.pngに更新
- Rails 7.0.0 → 7.2.0 - Puma 5.0 → 6.0 (Rack 3対応のため必須) - Ransack 3.1.0 → 最新版 (Rails 7.2対応) - rails-i18nのバージョン制約を削除
Rails 7.2でRails.application.secretsが削除されたため、 後方互換性のためにsecretsメソッドを追加し、環境変数から 設定を読み込むように変更。 変更内容: - application.rbにsecretsメソッドを追加 - 環境変数からstripe/webhook/open_aiの設定を読み込む - stripe.rbを環境変数使用に更新
AIAnswerCreator → AiAnswerCreator
ファイル名ai_answer_creator.rbに対して、クラス名を AIAnswerCreator → AiAnswerCreator に変更してZeitwerkの 命名規則に準拠させる
- 新しいデフォルト設定ファイル (new_framework_defaults_7_2.rb) - 更新されたbin/スクリプト - 更新された設定ファイル (application, boot, environments, initializers) - 更新されたpublic/エラーページとアイコン - 新しい406エラーページ
rails app:updateで上書きされたため、再度追加
Rails 7.2の新しいデフォルト設定を有効化
|
Important Review skippedMore than 25% of the files skipped due to max files limit. The review is being skipped to prevent a low-quality review. 156 files out of 264 files are above the max files limit of 100. Please upgrade to Pro plan to get higher limits. You can disable this status message by setting the WalkthroughRails 6.1 から 7.2 へのアップグレード。Gemfile とバージョン更新、フレームワーク設定の移行、命名規約の統一(API/FAQ/AI の大文字定数 → CamelCase)、ActiveStorage の非推奨 API 置換、GoodJob 関連の多数マイグレーション、アセットパス修正、エラーページ差替えが含まれる。 Changes
Sequence Diagram(s)sequenceDiagram
participant Req as Request
participant App as Rails App
participant AS as ActiveStorage
rect rgba(200,220,255,0.6)
Note over App,AS: 旧(Rails 6.x)
Req->>App: HTTP リクエスト
App->>AS: ActiveStorage::Current.host = request.base_url
AS-->>AS: 保存(host)
end
rect rgba(200,255,220,0.6)
Note over App,AS: 新(Rails 7.x)
Req->>App: HTTP リクエスト
App->>AS: ActiveStorage::Current.url_options = { host:, port:, protocol: }
AS-->>AS: 保存(url_options ハッシュ)
end
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes 特に注意すべき箇所:
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings, 1 inconclusive)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/models/ai_answer_creator.rb (1)
6-7: 無限ループの危険性が確認されました。AIAnswerCreateJob のジョブ実行時の question.update が再度イベントを発火し、AiAnswerCreator が無限に再実行されます。以下の原因が特定されました:
AiAnswerCreatorは'question.update'イベントにサブスクライブされている(config/initializers/active_support_notifications.rb:57-58)- ジョブ内の
question.update(ai_answer:)が'question.update'イベントを発火する- 再び
AiAnswerCreator.callが実行され、ai_answer: ''に上書きしてAIAnswerCreateJob.perform_laterを再度積む- ループ継続
対応例:
- ジョブ側で
update_columnsを使用してイベント発火を回避する- または
AiAnswerCreatorにai_answer.blank?の判定ガード条件を追加する
♻️ Duplicate comments (2)
public/500.html (1)
1-66: エラーページの言語変更について確認が必要です。422.htmlと同様に、このエラーページも日本語から英語に変更されています。プロジェクトの言語方針との整合性を確認してください。
public/404.html (1)
1-67: エラーページの言語変更について確認が必要です。404.htmlも422.html、500.htmlと同様に日本語から英語に変更されています。3つのエラーページすべてが英語化されているため、これが意図的な方針変更なのか、それとも一時的なものなのかを確認してください。
🧹 Nitpick comments (2)
app/javascript/stylesheets/lp/blocks/lp/_lp-top-cover.sass (1)
54-57: 冗長なカラープロパティの削除。54行目の
color: var(--reversal-text)は57行目のcolor: var(--main)に上書きされるため、54行目は不要です。.lp-top-cover__title - color: var(--reversal-text) font-feature-settings: "palt" background-color: var(--accent) color: var(--main)config/initializers/stripe.rb (1)
5-5: 環境変数の存在確認を追加することを検討してください。
Rails.application.secretsからENVへの移行は適切ですが、本番環境では環境変数が未設定の場合に起動を停止させる検証を追加することを推奨します。以下のような実装を検討してください:
-Stripe.api_key = ENV['STRIPE_SECRET_KEY'] +if Rails.env.production? + Stripe.api_key = ENV.fetch('STRIPE_SECRET_KEY') do + raise 'STRIPE_SECRET_KEY environment variable is not set' + end +else + Stripe.api_key = ENV['STRIPE_SECRET_KEY'] +endBased on learnings
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
Gemfile.lockis excluded by!**/*.lockapp/javascript/images/background/people.pngis excluded by!**/*.pngpublic/icon.pngis excluded by!**/*.pngpublic/icon.svgis excluded by!**/*.svg
📒 Files selected for processing (37)
Gemfile(4 hunks)app/controllers/application_controller.rb(1 hunks)app/helpers/faq_helper.rb(1 hunks)app/javascript/packs/lp.js(1 hunks)app/javascript/stylesheets/lp/blocks/lp/_lp-top-cover.sass(1 hunks)app/models/ai_answer_creator.rb(1 hunks)bin/rails(1 hunks)bin/rake(0 hunks)bin/rubocop(1 hunks)bin/setup(1 hunks)bin/webpack(1 hunks)bin/webpack-dev-server(1 hunks)config/application.rb(2 hunks)config/boot.rb(1 hunks)config/environments/development.rb(4 hunks)config/environments/production.rb(3 hunks)config/environments/test.rb(2 hunks)config/initializers/active_support_notifications.rb(1 hunks)config/initializers/assets.rb(1 hunks)config/initializers/content_security_policy.rb(1 hunks)config/initializers/filter_parameter_logging.rb(1 hunks)config/initializers/inflections.rb(1 hunks)config/initializers/new_framework_defaults_7_0.rb(1 hunks)config/initializers/new_framework_defaults_7_2.rb(1 hunks)config/initializers/permissions_policy.rb(1 hunks)config/initializers/stripe.rb(1 hunks)config/puma.rb(1 hunks)config/webpacker.yml(0 hunks)db/migrate/20251106114043_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb(1 hunks)db/schema.rb(50 hunks)public/404.html(1 hunks)public/406-unsupported-browser.html(1 hunks)public/422.html(1 hunks)public/500.html(1 hunks)public/robots.txt(1 hunks)test/application_system_test_case.rb(1 hunks)test/test_helper.rb(1 hunks)
💤 Files with no reviewable changes (2)
- config/webpacker.yml
- bin/rake
🧰 Additional context used
📓 Path-based instructions (3)
**/*.rb
⚙️ CodeRabbit configuration file
**/*.rb: # refactoring
- まずFat Controllerを避け、次にFat Modelを避ける。
- Serviceクラスの乱用を避ける。
- controller concernを作ろうとしたらPORO(Plain Old Ruby Object)やActiveRecordモデルでの実装で代替できないか検討する。
Rails Patterns
- ViewHelperにメソッドを実装する時にはまずDecoratorパターンを使うことを検討する。(active_decorator gemを導入しているのでそれを使う)
- 複雑なActiveRecordクエリがあり、再利用できそうな場合はQueryObjectパターンを検討する。(rails-patterns gemを導入しているのでそれのQuery機能を使う)
- Viewにpartialを作る場合はViewComponentを使うことを検討する。
- 複数のActiveRecordモデルを操作する1つの責務がある時や外部APIとやりとりする処理がある場合にはInteractorオブジェクトパターンを検討する。(interactor gemを導入しているのでそれを使う)
- 複数のInteractorを実行するような処理がある場合Organizerオブジェクトパターンを検討する。(interactor gemを導入しており、その中にOrganizerの機能があるので使う)
Files:
app/helpers/faq_helper.rbconfig/boot.rbconfig/initializers/content_security_policy.rbconfig/application.rbapp/controllers/application_controller.rbconfig/puma.rbconfig/environments/development.rbtest/test_helper.rbconfig/initializers/stripe.rbconfig/initializers/permissions_policy.rbconfig/initializers/new_framework_defaults_7_2.rbconfig/initializers/active_support_notifications.rbdb/migrate/20251106114043_remove_not_null_on_active_storage_blobs_checksum.active_storage.rbconfig/initializers/filter_parameter_logging.rbconfig/environments/production.rbconfig/initializers/new_framework_defaults_7_0.rbconfig/initializers/assets.rbtest/application_system_test_case.rbconfig/environments/test.rbapp/models/ai_answer_creator.rbconfig/initializers/inflections.rbdb/schema.rb
**/*.js
⚙️ CodeRabbit configuration file
**/*.js: - どうしても避けられない時以外に新規にVue.js, Reactのコードを追加しない。
- fetchメソッドの代わりにrequest.jsを使う。
Files:
app/javascript/packs/lp.js
test/**/*
⚙️ CodeRabbit configuration file
test/**/*: # Test
- TestCase名は英語で書く。
- どうしても避けられない時以外にsystem testでsleepは使わない。
Unit Test
model, helper, decorator, view_componentについてはメソッドを追加した場合は必ず対応したUnit TestのTestCaseを1つは書く。
Files:
test/test_helper.rbtest/application_system_test_case.rb
🧠 Learnings (22)
📓 Common learnings
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/notifiers/discord_notifier.rb:131-135
Timestamp: 2025-09-12T21:18:00.834Z
Learning: Rails アップグレードPRにおいて、product_review_not_completed メソッドの webhook URL 設定の shared フォールバック追加も、設定システム全体の変更として別PRで対応すべきである。
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/models/graduation_notifier.rb:23-28
Timestamp: 2025-09-12T21:16:47.639Z
Learning: Rails upgrade PRにおいて、configuration systemの変更やwebhook設定の改善提案も、アップグレードに直接関連しない場合は別PRで対応すべきである。PRのスコープ維持が重要。
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/notifiers/discord_notifier.rb:19-23
Timestamp: 2025-09-12T21:17:26.029Z
Learning: Rails アップグレードPRにおいて、config_for(:secrets) を使った webhook URL 設定の shared セクション未参照問題は、設定システム全体の変更として別PRで対応すべきである。
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/models/product.rb:59-61
Timestamp: 2025-09-11T14:47:53.256Z
Learning: Rails アップグレードPRでは、アップグレードに直接関連しない性能改善や機能追加の提案は避けるべき。PRのスコープを維持することが重要で、そのような改善提案は別PRで対応すべきである。
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/notifiers/discord_notifier.rb:52-56
Timestamp: 2025-09-12T21:17:45.295Z
Learning: Rails upgrade PRにおいて、configuration systemの改善提案(shared configuration fallback等)も、アップグレードに直接関連しない場合は別PRで対応すべきである。PRのスコープ維持が重要。
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: config/initializers/sorcery.rb:0-0
Timestamp: 2025-09-11T16:02:24.782Z
Learning: Rails アップグレードPRにおいて、JWT設定の改善では複数のソース(secrets, credentials, ENV)を優先順位付きで検索し、本番環境では未設定時に起動を停止させる実装が推奨される。開発・テスト環境でのみsecret_key_baseフォールバックを許可する構成が安全である。
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 9102
File: db/migrate/20250831234516_remove_unique_index_from_buzzes_title.rb:1-5
Timestamp: 2025-09-04T01:50:47.773Z
Learning: fjordllc/bootcampプロジェクトでは、マイグレーションにおいてdisable_ddl_transaction!やalgorithm: :concurrentlyは使用せず、標準的なRailsのchangeメソッド内でremove_indexを実行する慣例がある。
Learnt from: tyrrell-IH
Repo: fjordllc/bootcamp PR: 8807
File: app/views/welcome/job_support.html.slim:391-392
Timestamp: 2025-06-21T22:30:20.116Z
Learning: このプロジェクトにはRailsの組み込みmarkdownヘルパが利用できないため、markdownのHTML変換には自前でヘルパを実装する必要がある。
📚 Learning: 2025-09-12T12:53:17.172Z
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: public/500.html:2-64
Timestamp: 2025-09-12T12:53:17.172Z
Learning: エラーページ(404.html、422.html、500.html)について不正確な提案をした場合は、実際のファイル内容を確認してから回答すべき。これらのファイルは既に統一されており、追加のメタタグは不要だった。
Applied to files:
public/500.htmlpublic/404.htmlpublic/422.html
📚 Learning: 2025-06-21T22:30:20.116Z
Learnt from: tyrrell-IH
Repo: fjordllc/bootcamp PR: 8807
File: app/views/welcome/job_support.html.slim:391-392
Timestamp: 2025-06-21T22:30:20.116Z
Learning: このプロジェクトにはRailsの組み込みmarkdownヘルパが利用できないため、markdownのHTML変換には自前でヘルパを実装する必要がある。
Applied to files:
public/500.htmlpublic/422.html
📚 Learning: 2025-07-07T05:28:03.676Z
Learnt from: su-su-su-su
Repo: fjordllc/bootcamp PR: 0
File: :0-0
Timestamp: 2025-07-07T05:28:03.676Z
Learning: fjordllc/bootcampプロジェクトでは、fixtureファイル内のERB構文で改行制御文字(-)は使用せず、標準的な<% %>と<%= %>のみを使用する方針が統一されている。<% -%>や<%- %>を使用するとSyntaxErrorが発生する。
Applied to files:
config/boot.rbconfig/initializers/assets.rbbin/setup
📚 Learning: 2025-09-11T16:02:24.782Z
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: config/initializers/sorcery.rb:0-0
Timestamp: 2025-09-11T16:02:24.782Z
Learning: Rails アップグレードPRにおいて、JWT設定の改善では複数のソース(secrets, credentials, ENV)を優先順位付きで検索し、本番環境では未設定時に起動を停止させる実装が推奨される。開発・テスト環境でのみsecret_key_baseフォールバックを許可する構成が安全である。
Applied to files:
config/initializers/content_security_policy.rbconfig/application.rbconfig/environments/development.rbconfig/initializers/stripe.rbconfig/initializers/new_framework_defaults_7_2.rbbin/webpack-dev-serverconfig/initializers/filter_parameter_logging.rbconfig/environments/production.rbconfig/initializers/new_framework_defaults_7_0.rbbin/webpackconfig/initializers/assets.rbconfig/environments/test.rbGemfile
📚 Learning: 2025-09-12T21:17:26.029Z
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/notifiers/discord_notifier.rb:19-23
Timestamp: 2025-09-12T21:17:26.029Z
Learning: Rails アップグレードPRにおいて、config_for(:secrets) を使った webhook URL 設定の shared セクション未参照問題は、設定システム全体の変更として別PRで対応すべきである。
Applied to files:
config/application.rbconfig/environments/development.rbconfig/initializers/stripe.rbconfig/initializers/filter_parameter_logging.rbconfig/environments/production.rbconfig/initializers/new_framework_defaults_7_0.rbconfig/initializers/assets.rbconfig/environments/test.rb
📚 Learning: 2025-09-04T01:50:47.773Z
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 9102
File: db/migrate/20250831234516_remove_unique_index_from_buzzes_title.rb:1-5
Timestamp: 2025-09-04T01:50:47.773Z
Learning: fjordllc/bootcampプロジェクトでは、マイグレーションにおいてdisable_ddl_transaction!やalgorithm: :concurrentlyは使用せず、標準的なRailsのchangeメソッド内でremove_indexを実行する慣例がある。
Applied to files:
config/application.rbdb/migrate/20251106114043_remove_not_null_on_active_storage_blobs_checksum.active_storage.rbdb/schema.rb
📚 Learning: 2025-09-12T21:17:45.295Z
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/notifiers/discord_notifier.rb:52-56
Timestamp: 2025-09-12T21:17:45.295Z
Learning: Rails upgrade PRにおいて、configuration systemの改善提案(shared configuration fallback等)も、アップグレードに直接関連しない場合は別PRで対応すべきである。PRのスコープ維持が重要。
Applied to files:
config/application.rbconfig/initializers/new_framework_defaults_7_0.rb
📚 Learning: 2025-09-12T21:16:47.639Z
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/models/graduation_notifier.rb:23-28
Timestamp: 2025-09-12T21:16:47.639Z
Learning: Rails upgrade PRにおいて、configuration systemの変更やwebhook設定の改善提案も、アップグレードに直接関連しない場合は別PRで対応すべきである。PRのスコープ維持が重要。
Applied to files:
config/application.rb
📚 Learning: 2025-09-04T01:27:23.422Z
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 9102
File: db/fixtures/buzzes.yml:0-0
Timestamp: 2025-09-04T01:27:23.422Z
Learning: The buzz_controller.rb and related data migration files were deleted as part of the Buzz page redesign, not just modified. The old single buzz page was completely replaced with a new buzzes (plural) listing page with year-based navigation and metadata structure.
Applied to files:
public/404.htmldb/schema.rb
📚 Learning: 2025-07-23T20:42:19.974Z
Learnt from: jun-kondo
Repo: fjordllc/bootcamp PR: 0
File: :0-0
Timestamp: 2025-07-23T20:42:19.974Z
Learning: fjordllc/bootcampプロジェクトでは、hタグ(見出し)の文言は日本語でハードコーディングする方針が確立されており、I18n対応は行わない。例:app/views/welcome/logo.html.slimでh2、h3タグが日本語でハードコーディングされている。
Applied to files:
public/404.html
📚 Learning: 2025-07-30T07:26:36.599Z
Learnt from: ryufuta
Repo: fjordllc/bootcamp PR: 8992
File: app/models/correct_answer_notifier.rb:23-23
Timestamp: 2025-07-30T07:26:36.599Z
Learning: Railsの標準的なヘルパーメソッド(例:`question_url`、`user_path`など)が通常の方法で使用されている場合、それらの動作テストは不要である。これらのメソッドはRailsフレームワーク自体でテストされており、アプリケーション固有のロジックではないため。
Applied to files:
test/test_helper.rb
📚 Learning: 2025-08-26T07:31:10.235Z
Learnt from: sekito1107
Repo: fjordllc/bootcamp PR: 9081
File: test/models/transcoder/movie_test.rb:0-0
Timestamp: 2025-08-26T07:31:10.235Z
Learning: Transcoder::Movie クラス(app/models/transcoder/movie.rb)では、Google::Cloud::Storage::FileVerificationError(Storage固有の例外)とGoogle::Cloud::Storage.new(メインクラス)の両方を使用しているため、テストファイルでは完全な google/cloud/storage gem の require が必要。google/cloud/errors gem だけでは不十分。
Applied to files:
test/test_helper.rb
📚 Learning: 2025-08-24T16:19:17.661Z
Learnt from: sekito1107
Repo: fjordllc/bootcamp PR: 9081
File: app/models/transcoder/client.rb:98-102
Timestamp: 2025-08-24T16:19:17.661Z
Learning: In Ruby on Rails ActiveStorage code, when accessing the same attachment property multiple times within a method, it's better to use consistent syntax (e.g., always use `.blob.key` rather than mixing `.key` and `.blob.key`) for better readability and maintainability.
Applied to files:
test/test_helper.rb
📚 Learning: 2025-08-27T03:06:37.725Z
Learnt from: sekito1107
Repo: fjordllc/bootcamp PR: 9081
File: app/models/transcoder/client.rb:103-107
Timestamp: 2025-08-27T03:06:37.725Z
Learning: In Ruby on Rails ActiveStorage code, when using safe navigation operators (&.) for validation, maintain consistency by using the validated variable in subsequent operations rather than re-dereferencing the same chain directly.
Applied to files:
test/test_helper.rb
📚 Learning: 2025-09-02T19:01:08.804Z
Learnt from: matuaya
Repo: fjordllc/bootcamp PR: 9108
File: app/models/after_user_retirement.rb:43-45
Timestamp: 2025-09-02T19:01:08.804Z
Learning: fjordllc/bootcampプロジェクトの`app/models/card.rb`は、ActiveRecordモデルではなくStripe APIをラップしたカスタムクラスである。`Card.destroy_all(customer_id)`メソッドは、指定されたcustomer_idに関連付けられたカードのみを削除するカスタム実装で、ActiveRecordの`destroy_all`とは動作が異なり安全である。
Applied to files:
config/initializers/stripe.rb
📚 Learning: 2025-08-22T01:55:06.329Z
Learnt from: sekito1107
Repo: fjordllc/bootcamp PR: 9081
File: app/models/transcoder/client.rb:8-13
Timestamp: 2025-08-22T01:55:06.329Z
Learning: In app/models/transcoder/client.rb, when adding nil guards for configuration access, it's better to place the validation in the default_storage_config method rather than in initialize, to centralize configuration validation and maintain readability.
Applied to files:
config/initializers/new_framework_defaults_7_0.rb
📚 Learning: 2025-09-08T04:55:46.649Z
Learnt from: sharoa119
Repo: fjordllc/bootcamp PR: 8711
File: db/schema.rb:0-0
Timestamp: 2025-09-08T04:55:46.649Z
Learning: In this PR, the removal of length limits from companies.name and companies.website columns in db/schema.rb was unintentional - it was a case of accidentally lost constraints that needed to be restored to their original limits, not a deliberate design change.
Applied to files:
db/schema.rb
📚 Learning: 2025-08-24T16:17:12.056Z
Learnt from: sekito1107
Repo: fjordllc/bootcamp PR: 9081
File: app/models/transcoder/client.rb:98-102
Timestamp: 2025-08-24T16:17:12.056Z
Learning: ActiveStorage::Attached::One delegates the `key` method to its associated blob, so `attachment.key` works the same as `attachment.blob.key` in Rails applications.
Applied to files:
db/schema.rb
📚 Learning: 2025-09-04T01:27:23.422Z
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 9102
File: db/fixtures/buzzes.yml:0-0
Timestamp: 2025-09-04T01:27:23.422Z
Learning: The buzz_controller.rb was indeed deleted, but there are still two remaining items from the old buzz single page implementation that need cleanup: the data migration file db/data/20230726024528_create_buzz.rb and the old buzz route in config/routes.rb line 136. These should be updated/removed to complete the buzz page redesign migration.
Applied to files:
db/schema.rb
📚 Learning: 2025-09-11T14:18:20.194Z
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: db/migrate/20250828192202_add_missing_columns_to_good_jobs.rb:4-10
Timestamp: 2025-09-11T14:18:20.194Z
Learning: GoodJobやその他の外部gemが生成するマイグレーションファイルは、gem内部のロジックと密接に連携しているため、null制約やデフォルト値の追加などの変更を行うべきではない。gemのアップグレードパスに従い、生成されたマイグレーションをそのまま使用することが適切。
Applied to files:
db/schema.rb
📚 Learning: 2025-07-15T12:33:04.885Z
Learnt from: reckyy
Repo: fjordllc/bootcamp PR: 8356
File: db/fixtures/users.yml:823-826
Timestamp: 2025-07-15T12:33:04.885Z
Learning: fjordllc/bootcampプロジェクトでは、`trainee: true`は「研修に所属していたユーザー」全体を示すフラグであり、研修中のユーザーと研修を終了したユーザーの両方を含む。そのため、`trainee: true`と`training_completed_at`の併存は意図された仕様であり、排他的な関係ではない。
Applied to files:
db/schema.rb
🧬 Code graph analysis (5)
config/environments/development.rb (1)
config/application.rb (1)
config(10-48)
config/environments/production.rb (1)
config/application.rb (1)
config(10-48)
config/initializers/assets.rb (1)
config/application.rb (1)
config(10-48)
test/application_system_test_case.rb (1)
test/system/notification/assigned_as_checker_test.rb (1)
deliveries(15-17)
config/environments/test.rb (1)
config/application.rb (1)
config(10-48)
🔇 Additional comments (26)
config/initializers/permissions_policy.rb (1)
1-13: ドキュメント更新として良い改善です。このファイルへの変更は主にドキュメント/フォーマットの改善であり、Rails 7.2 アップグレードの一環として適切です:
- Line 1: サーバー再起動の注記は Rails イニシャライザの標準的な慣例
- Line 4: "see:" への修正はドキュメント形式の統一化
- Line 6: ブロックパラメータを
fからpolicyへの変更により、サンプルコードの可読性が向上実質的な機能変更がないため、本番環境への影響はありません。
public/robots.txt (1)
1-1: このファイルの変更がRails 7.2アップグレードに関連しているか確認してください。
public/robots.txtの内容を、複数行の説明と「ban-all-spiders」ガイダンスから、単一行のドキュメンテーションコメントに変更するこの変更は、Rails 7.2アップグレードに直接関連していないように見えます。取得ガイダンスの削除は、SEOやクローラーの動作に影響を与える可能性があります。このPRのスコープを明確にしてください。このような設定ファイルの変更がアップグレードに直接関連していない場合は、別のPRで対応することをお勧めします。
app/javascript/stylesheets/lp/blocks/lp/_lp-top-cover.sass (2)
2-2: Asset URLパス形式をRails 7.2での正当性検証してください。
url('~images/background/people.png')の形式は、Webpack alias構文を示唆しています。この表記がRails 7.2のアセットパイプラインで正しく解決されることを確認してください。特に、アセットが実際にimages/background/people.pngに存在し、ビルド時に正しく参照されることをテストしてください。
6-14: Rails upgrade PRのスコープ確認:レスポンシブスタイリング追加が必要か明確にしてください。このPRでは多くのレスポンシブスタイリングが追加されています(メディアブレークポイント、padding-block、サイズ調整など)。提供されたレビング学習から、Rails アップグレードPRではアップグレードに直接関連しない改善提案は別PRで対応すべきであることが示されています。
これらのレスポンシブ設計の改善が:
- Rails 7.2へのアップグレードに直接必要なものか
- 単なるUI/UX改善であり、アップグレード後に別PRで実施すべきものか
を明確にしてください。スコープの明確化は、このPRのレビューと承認の判断に重要です。
Also applies to: 25-26, 42-44, 50-51, 61-66
db/schema.rb (4)
13-13: スキーマバージョンの更新を確認しました。マイグレーションによるスキーマバージョンの更新は適切です。
23-23: Rails 7.xのスキーマダンプ形式の変更を確認しました。タイムスタンプカラムに
precision: nilが明示的に設定されていますが、これはRails 7.xのスキーマダンプ形式の標準的な変更です。機能的な変更はありません。Also applies to: 35-35, 49-50, 54-54, 62-63, 72-73, 76-76, 89-90, 98-99, 108-109, 115-116, 120-121, 123-124, 131-132, 140-141, 151-152, 160-161, 168-169, 180-181, 189-190, 204-205, 214-215, 226-227, 237-239, 244-245, 252-253, 262-263, 275-276, 285-288, 290-291, 294-294, 302-304, 312-313, 321-322, 333-334, 344-345, 353-354, 362-364, 368-369, 374-375, 385-387, 389-390, 395-395, 424-425, 434-435, 442-443, 451-452, 461-462, 469-470, 476-477, 484-485, 493-494, 507-508, 515-516, 524-525, 527-527, 538-539, 551-552, 565-566, 581-582, 589-590, 599-600, 603-603, 616-616, 620-624, 634-635, 645-646, 664-665, 673-674, 690-691, 693-693, 695-697, 708-709, 712-712, 722-723, 731-732, 741-742, 751-752, 762-763, 776-777, 780-780, 787-788, 796-797, 801-801, 813-814, 821-824, 830-831, 838-839, 846-847, 858-859, 867-868, 880-881, 889-892, 900-901, 912-912, 932-933, 943-944, 946-946, 952-952, 957-958, 987-988, 1007-1007, 1019-1020, 1032-1033
613-629: 新規テーブルの追加がRailsアップグレードPRに含まれています。
pair_worksテーブルとschedulesテーブルが新規追加されていますが、これらはペアワーク機能の追加に見えます。Rails 7.2へのアップグレードとは直接関係のない機能追加のようです。学習された内容によると、Railsアップグレードに直接関連しない機能追加や変更は別PRで対応すべきとされています。これらのテーブルがRails 7.2のアップグレードに必須でない場合は、別PRに分離することをご検討ください。
Based on learnings
Also applies to: 819-825
1075-1077: 新規テーブルの外部キー制約が追加されています。
pair_worksとschedulesテーブルの外部キー制約は適切に定義されています。ただし、これらの新規テーブルが別PRに分離される場合は、これらの外部キー定義も一緒に移動する必要があります。Also applies to: 1098-1098
bin/rubocop (1)
5-7: コード変更は適切です。検証完了。
.rubocop.ymlがプロジェクトルートに存在することを確認しました(425 bytes)。実装は正しく、明示的な--config指定により、RuboCopの設定ファイル検索を省略してパフォーマンス向上が期待できます。ARGV.unshiftを用いた実装も標準的で問題ありません。config/boot.rb (1)
1-1: LGTM!文字列リテラルのクォート変更は、Rails 7の規約に沿った形式的な変更です。機能的な影響はありません。
bin/webpack-dev-server (1)
5-5: OpenSSL legacy provider の使用を確認してください。
--openssl-legacy-providerフラグは Node.js 17+ での後方互換性のための回避策です。これは古い暗号化アルゴリズムを使用する依存関係がある場合に必要ですが、技術的負債となる可能性があります。将来的には依存関係を更新して、このフラグを削除できるか検討してください。bin/rails (1)
2-2: LGTM!Spring プリローダーの削除とクォートスタイルの変更は、Rails 7 アップグレードに適切な変更です。
config/initializers/filter_parameter_logging.rb (1)
7-7: :email の追加は適切です。
:g-recaptchaの削除については、アプリケーションから reCAPTCHA が削除された場合は問題ありませんが、まだ使用している場合は残すべきです。public/406-unsupported-browser.html (1)
1-66: LGTM!サポートされていないブラウザ用の新しいエラーページの追加は適切です。スタイリングは Rails のデフォルトエラーページと一貫性があり、コンテンツも明確で分かりやすいです。
app/javascript/packs/lp.js (1)
13-13: インポートパスの検証が完了しました。ファイル
app/javascript/images/background/people.pngが正常に存在することが確認されたため、インポートパスは正しく設定されています。追加の対応は不要です。config/puma.rb (1)
23-34: レビューコメントは誤りです。Puma設定は変更されていません。
config/puma.rbは今回のコミットで変更されていません(git diffが空白)。前バージョン(HEAD~1)と現在のコードは同一です。レビューコメントで指摘されている「ワーカープロセス設定」と「
preload_app!」は、前バージョンの設定にもともと存在していません。削除されたわけではなく、以前から存在していない設定です。したがって、パフォーマンスへの影響やワーカー設定の復旧は検討不要です。
Likely an incorrect or invalid review comment.
config/initializers/inflections.rb (1)
7-16: コメント内のクォート変更のみで、実行時の影響はありません。Rails 7のコード規約統一の一環として、コメント内の文字列リテラルをシングルクォートからダブルクォートに変更しています。実際の動作には影響しません。
db/migrate/20251106114043_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb (1)
1-8: Rails 7へのActiveStorageマイグレーションとして適切です。ActiveStorageの標準的なマイグレーションで、
checksumカラムをnullable化しています。テーブル存在チェックも適切に実装されており、プロジェクトの慣例に従っています。config/environments/test.rb (1)
11-66: Rails 7.2のテスト環境設定として適切です。以下の変更はすべてRails 7.2の推奨設定に沿っています:
cache_classesからenable_reloadingへの移行- CI環境での
eager_loadの有効化show_exceptionsの:rescuableへの変更raise_on_missing_callback_actionsの追加による安全性向上public/422.html (1)
1-67: このレビューコメントは部分的に不正確です。Git diffから確認したところ、実際には:
- 422.htmlのみが変更されました - 日本語版から英語のRailsデフォルトエラーページへの変更は事実です
- 404.html と 500.html は このPRでは変更されていません - これらのファイルは既にメインブランチで英語版として存在していたため、変更対象ではありません
レビューコメント内の「404.html、500.htmlも同様に英語化されている」という記述は誤りです。
加えて、エラーページを日本語にする必要があるというプロジェクトポリシーの明確な根拠も確認できません。エラーページはシステムレベルのコンポーネントであり、Railsのデフォルト設定として英語版を使用することは一般的な慣行です。
Likely an incorrect or invalid review comment.
config/initializers/assets.rb (1)
12-12: レビューコメントは不適切です。削除されたアセット設定は問題ありません。プロジェクトは Webpacker 5.4.3 を使用しており、CSS コンパイルは Rails Sprockets ではなく webpack で処理されています。
app/javascript/stylesheets/に配置された SASS ファイル(application.sass、lp.sass、not-logged-in.sass)は、Webpacker の webpack ローダーによって正常にバンドルされます。
Rails.application.config.assets.precompileは Sprockets 専用の設定です。Webpacker ベースのアプリケーションでは不要であり、コメントアウトされた行を削除することは正しい対応です。Likely an incorrect or invalid review comment.
Gemfile (4)
52-52: net-smtp の TODO コメント削除は正しい対応です。Rails 7.0.1 以降では net-smtp の処理が改善されたため、TODO コメントの削除は適切です。
96-97: Spring の廃止は Rails 7 での正しい対応です。Rails 7 では Spring が非推奨となったため、コメントアウトと注記の追加は適切です。
12-14: Gemfile の Rails 7.2 へのアップグレードは正しく対応されています。Rails 7.2 では
railsgem がsprockets-railsに依存しなくなったため、Asset Pipeline を使用する場合は Gemfile に明示的に追加する必要があります。Puma 6.0 への更新も含め、全ての変更が適切です。
66-66: 元のレビューコメントは根拠がありません。Ransack は Rails 7.2 をサポートしており、GitHub README で Rails 8.0、7.2、7.1 がサポート対象として明記されています(Ruby 3.1+ 必須)。したがって、ransack のバージョン制約を削除することは互換性リスクではなく、むしろ最新のパッチアップデートを自動で受け取ることができるメリットがあります。
Likely an incorrect or invalid review comment.
config/initializers/active_support_notifications.rb (1)
56-58: 旧クラス名の参照漏れは確認されません
リポジトリ全体を検索した結果、旧クラス名AIAnswerCreatorへの参照は存在しません。config/initializers/active_support_notifications.rb:56-58 で新しいAiAnswerCreatorに適切に差し替わっており、Rails 7.2 / Zeitwerk での定数不足エラーは発生しません。
ef3d386 to
44c9d33
Compare
Zeitwerk naming conventionに従い、以下のクラス名を修正: - FAQ → Faq (モデル、コントローラー、ビュー、テスト) - FAQCategory → FaqCategory - FAQHelper → FaqHelper - Admin::FAQCategories → Admin::FaqCategories - API:: → Api:: (全APIコントローラー) - AIAnswerCreateJob → AiAnswerCreateJob - AI::AnswerGenerator → Ai::AnswerGenerator また、Zeitwerkの自動読み込みと競合するため以下を削除: - WelcomeControllerのrequire_dependency 'faq_category' その他の修正: - Rails.application.secrets.secret_key_base → Rails.application.secrets[:secret_key_base]
44c9d33 to
57e3ce7
Compare
rails app:updateでbin/setupが更新された際に削除されたYarn インストールステップを復元。 Webpacker 5.0を使用しているプロジェクトでは、package.jsonと yarn.lockの依存関係をインストールする必要があるため、 package.jsonの存在を確認してyarn installを実行するように変更。
rails app:updateで本番環境のActive Storage serviceが:localに 上書きされていたため、元の:googleに戻す。 - config.active_storage.service = :google - config.active_storage.service_urls_expire_in = 7.days :localのままだと、アップロードされたファイルが各アプリサーバの ローカルディスクに保存され、再デプロイ時に失われる問題がある。
parallelize_setup内でActive StorageのrootパスをPathnameオブジェクト から文字列に変換してしまっていた問題を修正。 修正前: ActiveStorage::Blob.service.instance_variable_set(:@root, "#{original_root}/storage-#{i}") 修正後: ActiveStorage::Blob.service.instance_variable_set(:@root, original_root.join("storage-#{i}")) 文字列補間ではなくPathname#joinメソッドを使用することで、 Pathname型を維持し、後続の処理でNoMethodErrorが発生しないようにする。
- Rails.application.routes.default_url_optionsを設定 - ActionDispatch::IntegrationTestにhost!設定を追加 - URL生成時のホスト不一致エラーを解消
Rails 7.2のUnsafeRedirectError対策として redirect_back_or_toにallow_other_host: trueを追加。
テスト環境のデフォルトホストがwww.example.comに 変更されたため、テストの期待値を更新。
メール送信の非同期処理に対応するため、 perform_enqueued_jobsブロックでメール送信をラップ。
9431feb to
c32e7b1
Compare
Rails 8.0でキーワード引数形式のenumが削除されるため、
全てのenumを新しい位置引数形式に変更。
変更内容:
- `enum attribute: { ... }` → `enum :attribute, { ... }`
- `_prefix: true` → `prefix: true`
- `_suffix: true` → `suffix: true`
影響範囲:
- User (job, os, editor, satisfaction, referral_source, career_path)
- Report (emotion)
- Announcement (target)
- RegularEvent (category)
- Notification (kind)
- CodingTest (language)
- SurveyQuestion (format)
- Learning (status)
- Article (thumbnail_type, target)
- Reaction (kind)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
- company_decorator_test.rb: テスト環境のdefault_url_optionsに合わせてURL期待値をlocalhost:3000に変更 - question_integration_test.rb: - Rails 7.2のintegration testでfollow_redirect!がセッションを維持しない問題に対応 - 不要なauthenticity_tokenパラメータを削除(integration testではCSRF保護が無効) - ログイン処理を簡略化 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Redirection#determin_urlをpolymorphic_urlからpolymorphic_pathに変更 - Rails 7.2のsystem testでUnsafeRedirectErrorを回避するため相対パスを使用 - これによりMarkdownTestやNotification::QuestionsTestが正常に動作するようになった 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
テスト環境のdefault_url_optionsがlocalhost:3000に設定されているため、 メーラーテストの期待値もwww.example.comからlocalhost:3000に変更。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
大文字のFAQ定数を小文字のFaqに修正し、モデル名との整合性を保つ。
Rails 7.2では外部キー検証が厳格になったため、空のsurvey_answersフィクスチャファイルを作成して外部キー制約エラーを回避。
survey_answersと同様に空のフィクスチャファイルを作成して外部キー制約エラーを回避。
inflectorの設定でbuzzの複数形をbuzzesに明示的に指定して、テーブル名エラーを修正。
Date.parseからTime.zone.local with 09:00に変更して、タイムゾーンを考慮した日時設定に修正。
Time.zone.localの代わりにActiveSupport::TimeZone['Asia/Tokyo'].localを使用して明示的にタイムゾーンを指定。
Capybara.server_hostを127.0.0.1に設定し、リダイレクト時のERR_CONNECTION_REFUSEDエラーを修正。
Capybara.server_portを固定するとログインが失敗するため、動的割り当てに変更し、app_hostのみ設定。
ポート番号を常にURLに含めるようにしてリダイレクトを修正。
Capybaraが127.0.0.1を使用するため、action_mailer/action_controllerのdefault_url_optionsも127.0.0.1に統一し、動的ポート割り当てに対応するためポート番号指定を削除。
フィクスチャの日時が00:00で保存されるため、テストの期待値も00:00に修正。
Rails 7.2では`to_s(:delimited)`がSymbolを引数として受け付けなくなったため、`number_with_delimiter`ヘルパーを使用するように変更。
Rails 7.2では一部の状況でfootprint.userがnilになることがあるため、present?チェックを追加してエラーを回避。
Time.currentがUTCを返していたため、I18n.lでの日時表示が 9時間ずれていた問題を修正。config.time_zoneをTokyoに設定することで フィクスチャの時刻表示が正しくJSTで表示されるようになった。
|
@machida もしこちら不要でしたら削除をおねがいします〜 |
Summary by CodeRabbit
新機能
バグ修正 / 改善
Chores