instance method
match
Ruby on Rails 5.2.8.1
Since v3.0.20Signature
match(path, *rest, &block)
Matches a URL pattern to one or more routes. For more information, see match.
match 'path' => 'controller#action', via: :patch
match 'path', to: 'controller#action', via: :post
match 'path', 'otherpath', on: :member, via: :get
Parameters
-
pathreq -
restrest -
blockblock
Source
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 1580
def match(path, *rest, &block)
if rest.empty? && Hash === path
options = path
path, to = options.find { |name, _value| name.is_a?(String) }
raise ArgumentError, "Route path not specified" if path.nil?
case to
when Symbol
options[:action] = to
when String
if to =~ /#/
options[:to] = to
else
options[:controller] = to
end
else
options[:to] = to
end
options.delete(path)
paths = [path]
else
options = rest.pop || {}
paths = [path] + rest
end
if options.key?(:defaults)
defaults(options.delete(:defaults)) { map_match(paths, options, &block) }
else
map_match(paths, options, &block)
end
end
Defined in actionpack/lib/action_dispatch/routing/mapper.rb line 1580
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionDispatch::Routing::Mapper::Resources