aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/journey/route.rb
diff options
context:
space:
mode:
authorAlberto Almagro <albertoalmagro@gmail.com>2018-12-08 22:42:40 +0100
committerAlberto Almagro <albertoalmagro@gmail.com>2019-05-22 23:03:54 +0200
commitfb9117e190e39872fff7ae5d6b96bfb26ef8b32c (patch)
tree6269b64939b1a15b672c1deb4b871b3b3e9256fb /actionpack/lib/action_dispatch/journey/route.rb
parentd5a2f7ec148726d7547e367d7a968e3b4be9b509 (diff)
downloadrails-fb9117e190e39872fff7ae5d6b96bfb26ef8b32c.tar.gz
rails-fb9117e190e39872fff7ae5d6b96bfb26ef8b32c.tar.bz2
rails-fb9117e190e39872fff7ae5d6b96bfb26ef8b32c.zip
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
Diffstat (limited to 'actionpack/lib/action_dispatch/journey/route.rb')
-rw-r--r--actionpack/lib/action_dispatch/journey/route.rb9
1 files changed, 5 insertions, 4 deletions
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