module Rad module ControllerRoutingHelper inherit 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 %(
You are being redirected.) end # Flash need to know if we using redirect keep_flash! throw :halt_render, content end end end