我看到下面的頁面上未經授權使用401個重定向軌道4,5:重定向狀態:401掛在「您正在重定向。」我如何強制重定向?
我很好此頁面的渲染,但不與網頁掛確定。
帶錨文本「重定向」的鏈接可以在重定向到正確的頁面時正常工作,但必須單擊該鏈接。換句話說,該消息是不正確的,我沒有被主動重定向。
如何強制重定向?
這裏是可以實現這一目的的代碼,在action_controller/metal
def redirect_to(options = {}, response_status = {}) #:doc:
raise ActionControllerError.new("Cannot redirect to nil!") unless options
raise AbstractController::DoubleRenderError if response_body
self.status = _extract_redirect_to_status(options, response_status)
self.location = _compute_redirect_to_location(request, options)
self.response_body = "<html><body>You are being <a href=\"#{ERB::Util.unwrapped_html_escape(location)}\">redirected</a>.</body></html>"
end
使用JavaScript與setTimeout – Leon
好主意,但我怎麼讓js到ru n在佈局中:僅用於此視圖的false環境 – Abram
將其添加到視圖本身並使用vanilla JS作爲jquery可能未加載。 – Leon