Sha256: 627e093d0926733a4a16c8c4e5fad004cdbb6020592d09b7a5b20aab461152c4
Contents?: true
Size: 1.24 KB
Versions: 24
Compression:
Stored size: 1.24 KB
Contents
module Rad::ControllerRoutingHelper inherit Rad::AbstractRoutingHelper module ClassMethods # # persist_params controller filters # def persist_params *args if args.empty? before :persist_params elsif args.first.is_a? Hash before :persist_params, args.first else before :persist_params, only: args.first end end end # # redirect_to # 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 end
Version data entries
24 entries across 24 versions & 1 rubygems