Methods

Class Index [+]

Quicksearch

Merb::Rack::Helpers

Public Class Methods

redirect(url, options = {}) click to toggle source

A helper to build a rack response which implements a redirect. The status will be set to the passed in status if passed. If you pass in permanent it will be a 301, permanent redirect, otherwise it defaults to a temporary 302 redirect.

Parameters

url<~to_s>

The url to redirect to.

options

A hash of options for the redirect

  status: The status code to use for the redirect
  permanent:  True if this is a permanent redirect (301)

Returns

A rack response to redirect to the specified url.

:api: plugin

    # File lib/merb-core/rack/helpers.rb, line 19
19:       def self.redirect(url, options = {})
20:         # Build the rack array
21:         status   = options.delete(:status)
22:         status ||= options[:permanent] ? 301 : 302
23:         
24:         Merb.logger.info("Dispatcher redirecting to: #{url} (#{status})")
25:         Merb.logger.flush
26:         
27:         [status, { Merb::Const::LOCATION => url },
28:          Merb::Rack::StreamWrapper.new("<html><body>You are being <a href=\"#{url}\">redirected</a>.</body></html>")]
29:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.