Define a route that only recognizes HTTP PUT. For supported arguments, see match.
Example:
delete ‘broccoli’, :to => ‘food#‘
# File lib/action_dispatch/routing/mapper.rb, line 341
341: def delete(*args, &block)
342: map_method(:delete, *args, &block)
343: end
Define a route that only recognizes HTTP GET. For supported arguments, see match.
Example:
get ‘bacon’, :to => ‘food#‘
# File lib/action_dispatch/routing/mapper.rb, line 311
311: def get(*args, &block)
312: map_method(:get, *args, &block)
313: end
Define a route that only recognizes HTTP POST. For supported arguments, see match.
Example:
post ‘bacon’, :to => ‘food#‘
# File lib/action_dispatch/routing/mapper.rb, line 321
321: def post(*args, &block)
322: map_method(:post, *args, &block)
323: end
Define a route that only recognizes HTTP PUT. For supported arguments, see match.
Example:
put ‘bacon’, :to => ‘food#‘
# File lib/action_dispatch/routing/mapper.rb, line 331
331: def put(*args, &block)
332: map_method(:put, *args, &block)
333: end
Redirect any path to another path:
match "/stories" => redirect("/posts")
# File lib/action_dispatch/routing/mapper.rb, line 348
348: def redirect(*args, &block)
349: options = args.last.is_a?(Hash) ? args.pop : {}
350:
351: path = args.shift || block
352: path_proc = path.is_a?(Proc) ? path : proc { |params| path % params }
353: status = options[:status] || 301
354:
355: lambda do |env|
356: req = Request.new(env)
357:
358: params = [req.symbolized_path_parameters]
359: params << req if path_proc.arity > 1
360:
361: uri = URI.parse(path_proc.call(*params))
362: uri.scheme ||= req.scheme
363: uri.host ||= req.host
364: uri.port ||= req.port unless req.standard_port?
365:
366: body = %(<html><body>You are being <a href="#{ERB::Util.h(uri.to_s)}">redirected</a>.</body></html>)
367:
368: headers = {
369: 'Location' => uri.to_s,
370: 'Content-Type' => 'text/html',
371: 'Content-Length' => body.length.to_s
372: }
373:
374: [ status, headers, [body] ]
375: end
376: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.