From fb9117e190e39872fff7ae5d6b96bfb26ef8b32c Mon Sep 17 00:00:00 2001 From: Alberto Almagro Date: Sat, 8 Dec 2018 22:42:40 +0100 Subject: Keep part when scope option has value When a route was defined within an optional scope, if that route didn't take parameters the scope was lost when using path helpers. This patch ensures scope is kept both when the route takes parameters or when it doesn't. Fixes #33219 --- actionpack/lib/action_dispatch/journey/route.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'actionpack/lib/action_dispatch/journey/route.rb') diff --git a/actionpack/lib/action_dispatch/journey/route.rb b/actionpack/lib/action_dispatch/journey/route.rb index 8165709a3d..587ebcb873 100644 --- a/actionpack/lib/action_dispatch/journey/route.rb +++ b/actionpack/lib/action_dispatch/journey/route.rb @@ -4,9 +4,9 @@ module ActionDispatch # :stopdoc: module Journey class Route - attr_reader :app, :path, :defaults, :name, :precedence + attr_reader :app, :path, :defaults, :name, :precedence, :constraints, + :internal, :scope_options - attr_reader :constraints, :internal alias :conditions :constraints module VerbMatchers @@ -51,13 +51,13 @@ module ActionDispatch def self.build(name, app, path, constraints, required_defaults, defaults) request_method_match = verb_matcher(constraints.delete(:request_method)) - new name, app, path, constraints, required_defaults, defaults, request_method_match, 0 + new name, app, path, constraints, required_defaults, defaults, request_method_match, 0, {} end ## # +path+ is a path constraint. # +constraints+ is a hash of constraints to be applied to this route. - def initialize(name, app, path, constraints, required_defaults, defaults, request_method_match, precedence, internal = false) + def initialize(name, app, path, constraints, required_defaults, defaults, request_method_match, precedence, scope_options, internal = false) @name = name @app = app @path = path @@ -72,6 +72,7 @@ module ActionDispatch @decorated_ast = nil @precedence = precedence @path_formatter = @path.build_formatter + @scope_options = scope_options @internal = internal end -- cgit v1.2.3