Skip to content

Commit e589b1f

Browse files
Merge pull request rails#50403 from jonathanhefner/follow-up-46530
Fix inclusion of `url_helpers` module in concern
2 parents b0048c7 + 76c2613 commit e589b1f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

actionpack/lib/action_dispatch/routing/route_set.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ def url_options; {}; end
604604
# `included` block is run only for the initial inclusion of each copy.
605605
def self.included(base)
606606
super
607-
if !base._routes.equal?(@_proxy._routes)
607+
if base.respond_to?(:_routes) && !base._routes.equal?(@_proxy._routes)
608608
@dup_for_reinclude ||= self.dup
609609
base.include @dup_for_reinclude
610610
end

actionpack/test/dispatch/routing/custom_url_helpers_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,17 @@ def test_resolve_urls
301301
assert_equal "http://www.example.com/manufacturers/apple", Routes.url_helpers.polymorphic_url(@manufacturer)
302302
end
303303

304+
def test_url_helpers_module_can_be_included_directly_in_an_active_support_concern
305+
concern = Module.new do
306+
extend ActiveSupport::Concern
307+
include Routes.url_helpers
308+
end
309+
310+
concerned = Class.new { include concern }.new
311+
312+
assert_equal "http://www.example.com/", concerned.root_url
313+
end
314+
304315
def test_defining_direct_inside_a_scope_raises_runtime_error
305316
routes = ActionDispatch::Routing::RouteSet.new
306317

0 commit comments

Comments
 (0)