簡體   English   中英

如何在不使用 redirect_to 的情況下在 Rails 中重新呈現當前頁面?

[英]How can I re-render current page in Rails without using redirect_to?

我需要能夠做到

render 'current page', :notice => 'message'

使用redirect_to時通知丟失,可能是因為我在 active-admin 中執行此操作。 但它適用於render

您可以在這種情況下使用flash ,它可以跨 Web 請求保存鍵值對:

flash[:notice] => 'message'

redirect_to some_url

然后在您重定向到的 URL 的視圖中:

<h1><%= flash[:notice] %></h1>

其他參考: https : //api.rubyonrails.org/classes/ActionDispatch/Flash.html

暫無
暫無

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

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