Skip to content

Commit

Permalink
fix: wait rails initialize before include application routes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosgz committed Nov 21, 2024
1 parent 698fef9 commit 1ed90f3
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions lib/site_maps/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@

module SiteMaps
class Railtie < ::Rails::Railtie
module URLExtension
class NamedRoute
initializer "site_maps.named_routes" do
named_route = Class.new do
include Singleton
include ::Rails.application.routes.url_helpers
end

def route
NamedRoute.instance
end
end

initializer "site_maps.named_routes" do
SiteMaps::Adapters::Adapter.prepend(URLExtension)
SiteMaps::Adapters::Adapter.prepend(Module.new do
define_method(:route) { named_route.instance }
end)
end
end
end

0 comments on commit 1ed90f3

Please sign in to comment.