Skip to content

Commit fea24c9

Browse files
authored
Merge pull request #320 from francescob/main
fix for middleware generating empty routes with rails 8
2 parents 7b5731c + 622c477 commit fea24c9

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
include:
14+
include:
1515
- ruby: "2.7"
1616
gemfile: gemfiles/rails50_sprockets_3.gemfile
1717
- ruby: "2.7"
@@ -22,7 +22,6 @@ jobs:
2222
gemfile: gemfiles/rails70_sprockets_4.gemfile
2323
- ruby: "3.3"
2424
gemfile: gemfiles/rails80_sprockets_4.gemfile
25-
2625
env:
2726
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
2827
steps:

lib/js_routes/instance.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ def initialize(**options)
2424
sig {returns(String)}
2525
def generate
2626
# Ensure routes are loaded. If they're not, load them.
27+
2728
application = T.unsafe(self.application)
28-
if named_routes.empty? && application.respond_to?(:reload_routes!, true)
29-
application.reload_routes!
29+
if named_routes.empty?
30+
if Rails.version >= "8.0.0"
31+
application.reload_routes_unless_loaded
32+
elsif application.respond_to?(:reload_routes!, true)
33+
application.reload_routes!
34+
end
3035
end
3136
content = File.read(@configuration.source_file)
3237

0 commit comments

Comments
 (0)