Module: Rack::App::InstanceMethods::RedirectTo
- Included in:
- Rack::App::InstanceMethods
- Defined in:
- lib/rack/app/instance_methods/redirect_to.rb
Instance Method Summary collapse
Instance Method Details
#redirect_to(url, params = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rack/app/instance_methods/redirect_to.rb', line 3 def redirect_to(url, params={}) if params.empty? url = [url, request.env['QUERY_STRING']].join('?') unless request.env['QUERY_STRING'].empty? else query_string = Rack::Utils.build_nested_query(params) url = [url, query_string].join('?') end response.status = 301 response.headers['Location']= url finish! end |