Module: Rad::ControllerRoutingHelper
- Defined in:
- lib/rad/web/_router/controller_routing_helper.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#redirect_to(*args) ⇒ Object
redirect_to.
Instance Method Details
#redirect_to(*args) ⇒ Object
redirect_to
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rad/web/_router/controller_routing_helper.rb', line 23 def redirect_to *args params, response = workspace.params, workspace.response params.format.must_be.in 'html', 'js' if url = special_url(args.first) args.size.must_be <= 1 else url = url_for(*args) end content_type = Mime[params.format] content = if params.format == 'js' response.set!( status: :ok, content_type: content_type ) "window.location = '#{url}';" else response.set!( status: :redirect, content_type: content_type ) response.headers['Location'] = url %(<html><body>You are being <a href="#{url.html_escape if url}">redirected</a>.</body></html>) end # Flash need to know if we using redirect keep_flash! throw :halt, content end |