aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/mapper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/mapper.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 0cb02c5b80..bf10f81127 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -171,13 +171,13 @@ module ActionDispatch
end
def blocks
+ block = @scope[:blocks] || []
+
if @options[:constraints].present? && !@options[:constraints].is_a?(Hash)
- block = @options[:constraints]
- else
- block = nil
+ block << @options[:constraints]
end
- ((@scope[:blocks] || []) + [ block ]).compact
+ block
end
def constraints
@@ -345,11 +345,11 @@ module ActionDispatch
# Redirect any path to another path:
#
# match "/stories" => redirect("/posts")
- def redirect(*args, &block)
+ def redirect(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
- path = args.shift || block
- path_proc = path.is_a?(Proc) ? path : proc { |params| params.empty? ? path : (path % params) }
+ path = args.shift || Proc.new
+ path_proc = path.is_a?(Proc) ? path : proc { |params| (params.empty? || !path.match(/%\{\w*\}/)) ? path : (path % params) }
status = options[:status] || 301
lambda do |env|
@@ -1130,7 +1130,7 @@ module ActionDispatch
end
candidate = name.select(&:present?).join("_").presence
- candidate unless as.nil? && @set.routes.map(&:name).include?(candidate)
+ candidate unless as.nil? && @set.routes.find { |r| r.name == candidate }
end
end