Define a route that only recognizes HTTP PUT. For supported arguments, see
match
.
Example:
delete 'broccoli', :to => 'foodbroccoli'
# File lib/action_dispatch/routing/mapper.rb, line 352 def delete(*args, &block) map_method(:delete, *args, &block) end
Define a route that only recognizes HTTP GET. For supported arguments, see
match
.
Example:
get 'bacon', :to => 'foodbacon'
# File lib/action_dispatch/routing/mapper.rb, line 322 def get(*args, &block) map_method(:get, *args, &block) end
Define a route that only recognizes HTTP POST. For supported arguments, see
match
.
Example:
post 'bacon', :to => 'foodbacon'
# File lib/action_dispatch/routing/mapper.rb, line 332 def post(*args, &block) map_method(:post, *args, &block) end
Define a route that only recognizes HTTP PUT. For supported arguments, see
match
.
Example:
put 'bacon', :to => 'foodbacon'
# File lib/action_dispatch/routing/mapper.rb, line 342 def put(*args, &block) map_method(:put, *args, &block) end
Redirect any path to another path:
match "/stories" => redirect("/posts")
# File lib/action_dispatch/routing/mapper.rb, line 359 def redirect(*args, &block) options = args.last.is_a?(Hash) ? args.pop : {} path = args.shift || block path_proc = path.is_a?(Proc) ? path : proc { |params| path % params } status = options[:status] || 301 lambda do |env| req = Request.new(env) params = [req.symbolized_path_parameters] params << req if path_proc.arity > 1 uri = URI.parse(path_proc.call(*params)) uri.scheme ||= req.scheme uri.host ||= req.host uri.port ||= req.port unless req.standard_port? body = %Q(<html><body>You are being <a href="#{ERB::Util.h(uri.to_s)}">redirected</a>.</body></html>) headers = { 'Location' => uri.to_s, 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s } [ status, headers, [body] ] end end