From beafac5555377897318f4553766a88edaafd97d0 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 27 Oct 2024 03:42:00 +0900 Subject: [PATCH] path_helpers: Support Rails 8.0 Since Rails 8.0, route drawing has been defered to the first request. This forcedly do route drawing to scan path_helpers. refs: https://github.com/rails/rails/pull/52353 --- lib/rbs_rails/path_helpers.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/rbs_rails/path_helpers.rb b/lib/rbs_rails/path_helpers.rb index d21f4f4..afa6ba0 100644 --- a/lib/rbs_rails/path_helpers.rb +++ b/lib/rbs_rails/path_helpers.rb @@ -1,6 +1,10 @@ module RbsRails class PathHelpers def self.generate(routes: Rails.application.routes) + # Since Rails 8.0, route drawing has been defered to the first request. + # This forcedly do route drawing to scan path_helpers. + Rails.application.reload_routes_unless_loaded if Rails.application.respond_to?(:reload_routes_unless_loaded) + new(routes: Rails.application.routes).generate end