Rails Flash.now 不工作 [英] Rails Flash.now not working

查看:41
本文介绍了Rails Flash.now 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个视图,从中我向控制器发出 ajax 请求,在操作成功完成后,我初始化 flash.now[:notice].但是在控件返回视图之后.我没有看到 Flash 消息.

I have a view from which I make an ajax request to the controller and after the action is successfully completed I initialize the flash.now[:notice]. But after the control goes back to the view. I don't happen to see the flash message.

flash.now[:notice] = "Request Completed successfully" if @meetings.any?

推荐答案

重定向时使用

flash[:notice] = "This message value is available in next request-response cycle"

渲染时使用

flash.now[:notice] = "Message is available in same request-response cycle"

来自此处

这篇关于Rails Flash.now 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆