diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2018-09-26 11:10:25 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2018-09-26 11:10:25 -0700 |
commit | b50f7ae627a0962efbc1805b603f2d5baa6810d7 (patch) | |
tree | 56d5a47ac109f55e9b854aa95005f2609490e882 | |
parent | 6060a1d97bc02a47d9f41d9dc3208a33c2a1a696 (diff) | |
download | rails-b50f7ae627a0962efbc1805b603f2d5baa6810d7.tar.gz rails-b50f7ae627a0962efbc1805b603f2d5baa6810d7.tar.bz2 rails-b50f7ae627a0962efbc1805b603f2d5baa6810d7.zip |
Routes from Engine Railties should not be an infinite loop
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 183c386a0c..da4f285f61 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -444,8 +444,10 @@ module ActionDispatch end def include_helpers_now(klass, include_path_helpers) - if namespace = klass.parents.detect { |m| m.respond_to?(:railtie_routes_url_helpers) } - klass.include(namespace.railtie_routes_url_helpers(include_path_helpers)) + namespace = klass.parents.detect { |m| m.respond_to?(:railtie_include_helpers) } + + if namespace && namespace.railtie_namespace.routes != self + namespace.railtie_include_helpers(klass, include_path_helpers) else klass.include(url_helpers(include_path_helpers)) end diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 108d654ce3..901934826b 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -403,6 +403,12 @@ module Rails define_method(:railtie_helpers_paths) { railtie.helpers_paths } end + unless mod.respond_to?(:railtie_include_helpers) + define_method(:railtie_include_helpers) { |klass, include_path_helpers| + railtie.routes.include_helpers(klass, include_path_helpers) + } + end + unless mod.respond_to?(:railtie_routes_url_helpers) define_method(:railtie_routes_url_helpers) { |include_path_helpers = true| railtie.routes.url_helpers(include_path_helpers) } end |