簡體   English   中英

Rails redirect_to - 我也想重新加載頁面

[英]Rails redirect_to - I also want to the page to reload

Turbolinks 在整個應用程序中運行。 我需要在某個場景中在 create 方法中重新加載頁面。

這會重定向到正確的頁面,但不會重新加載頁面:

redirect_to convos_path


這會重定向到 convos_path,但不會重新加載頁面

redirect_to convos_path, data: { no_turbolink: true } and return

這沒有任何作用

redirect_to convos_path, turbolinks: false and return

我可以在服務器日志中看到它說

Rendered convos/index.html.erb within layouts/application (12.0ms)

如何執行redirect_to,並在頁面到達時重新加載頁面?

Rails 渦輪鏈接 5

重定向並重新加載整個頁面

redirect_to @convos_path, turbolinks: false

我從這里得到了解決方案。

<a data-turbolinks='false' href="url_here">Link Here</a>

對我來說,同一問題的解決方案與 turbolinks 無關。 確保您的表單沒有data-remote="true"屬性。

form_with是自 Rails 5.1 以來推薦的方式,默認情況下創建遠程表單,您必須顯式傳遞local: true

redirect_back(fallback_location:fallback_location)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM