Skip to content

Commit

Permalink
Merge pull request #1899 from bravehager/fix-routes-lazy-loading
Browse files Browse the repository at this point in the history
Handle deferred route drawing in URL helpers DSL compiler
  • Loading branch information
egiurleo committed May 14, 2024
2 parents ddcb901 + 191c0ad commit 871d641
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/tapioca/dsl/compilers/url_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ class << self
def gather_constants
return [] unless defined?(Rails.application) && Rails.application

# Load routes if they haven't been loaded yet (see https://github.com/rails/rails/pull/51614).
routes_reloader = Rails.application.routes_reloader
routes_reloader.execute_unless_loaded if routes_reloader&.respond_to?(:execute_unless_loaded)

Object.const_set(:GeneratedUrlHelpersModule, Rails.application.routes.named_routes.url_helpers_module)
Object.const_set(:GeneratedPathHelpersModule, Rails.application.routes.named_routes.path_helpers_module)

Expand Down

0 comments on commit 871d641

Please sign in to comment.