我通過建立一個作業板來學習 RoR,所以當有人訪問我的 Rails 作業的顯示頁面時,我試圖重定向到外部 URL。我正在嘗試按照以下邏輯進行操作,
單擊顯示頁面鏈接->檢查描述是否可用->是(然后轉到顯示頁面)->否(然后轉到顯示頁面 URL,然后自動重定向到與帖子關聯的相應外部 URL)
請幫我解決一下這個。謝謝。
uj5u.com熱心網友回復:
在您的表演動作中,您可以使用此方法
redirect_to 'https://stackoverflow.com', allow_other_host: true
閱讀更多:https ://api.rubyonrails.org/classes/ActionController/Redirecting.html#method-i-redirect_to
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/426343.html
