method
match
v4.1.8 -
Show latest stable
- Class:
ActionDispatch::Routing::Mapper::Scoping::Resources
match(path, *rest)public
match ‘path’ => ‘controller#action’ match ‘path’, to: ‘controller#action’ match ‘path’, ‘otherpath’, on: :member, via: :get
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 1421
def match(path, *rest)
if rest.empty? && Hash === path
options = path
path, to = options.find { |name, _value| name.is_a?(String) }
options[:to] = to
options.delete(path)
paths = [path]
else
options = rest.pop || {}
paths = [path] + rest
end
options[:anchor] = true unless options.key?(:anchor)
if options[:on] && !VALID_ON_OPTIONS.include?(options[:on])
raise ArgumentError, "Unknown scope #{on.inspect} given to :on"
end
if @scope[:controller] && @scope[:action]
options[:to] ||= "#{@scope[:controller]}##{@scope[:action]}"
end
paths.each do |_path|
route_options = options.dup
route_options[:path] ||= _path if _path.is_a?(String)
path_without_format = _path.to_s.sub(/\(\.:format\)$/, '')
if using_match_shorthand?(path_without_format, route_options)
route_options[:to] ||= path_without_format.gsub(%{^/}, "").sub(%{/([^/]*)$}, '#\1')
route_options[:to].tr!("-", "_")
end
decomposed_match(_path, route_options)
end
self
end Related methods
- Instance methods
- add_route
- collection
- decomposed_match
- match
- member
- namespace
- nested
- new
- resource
- resources
- resources_path_names
- root
- shallow
- shallow?
- using_match_shorthand?
- Protected methods
-
action_options? -
action_path -
apply_common_behavior_for -
canonical_action? -
name_for_action -
nested_options -
nested_scope? -
nesting_depth -
param_constraint -
param_constraint? -
parent_resource -
path_for_action -
prefix_name_for_action -
resource_method_scope? -
resource_scope -
resource_scope? -
scope_action_options -
scope_action_options? -
set_member_mappings_for_resource -
shallow_nesting_depth -
shallow_scope -
with_exclusive_scope -
with_scope_level