如何在多次重定向后显示 Flash 消息?
How to display a flash message after multiple redirects?
所以我试图在多次重定向后显示一个 flash,但我无法将其显示到 "keep"!我测试了我的视图文件中的代码,这是可靠的。我错过了什么?
if response["status"] == "NotProcessed"
redirect_to root_path, alert: "Does this work?"
这让我回到了根路径,但是没有显示 flash,所以我添加了
flash.keep,仍然没有。
我什至补充说:
def redirect_to(*args)
flash.keep
super
end
到我的应用程序控制器...但什么都没有!
谢谢!
已修复!
我在我的 ApplicationController 中设置了 protect_from_forgery with: :null_session
,因此它在每个会话中都删除了闪光灯。我删除了它,它工作正常。
我一定是在处理天气 API 的时候在应用程序的早期插入了它。
所以我试图在多次重定向后显示一个 flash,但我无法将其显示到 "keep"!我测试了我的视图文件中的代码,这是可靠的。我错过了什么?
if response["status"] == "NotProcessed"
redirect_to root_path, alert: "Does this work?"
这让我回到了根路径,但是没有显示 flash,所以我添加了 flash.keep,仍然没有。 我什至补充说:
def redirect_to(*args)
flash.keep
super
end
到我的应用程序控制器...但什么都没有!
谢谢!
已修复!
我在我的 ApplicationController 中设置了 protect_from_forgery with: :null_session
,因此它在每个会话中都删除了闪光灯。我删除了它,它工作正常。
我一定是在处理天气 API 的时候在应用程序的早期插入了它。