浏览 3800 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-10-23
其它的很多aciton中都会设置flash[:notice]的值,但是一旦跳出该action,flash[:notice]都会消失。 有谁碰到过类似的问题么?请教了 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-10-31
我已经找到问题的解决方法了,用flash.now[:notice],希望遇到同样问题的朋友可以借鉴一下。下面是原因:
flash[:notice] is meant only for redirect action, because the message is only cleared after at the end of redirected view request. So if you don’t redirect the request, and you click on the next request, that message will still be displayed. But sometimes, we just want to display custom error messages only for current request without the redirection (esp. for non-ActiveRecord error messages). So the option is to use flash.now[:notice]. It clears the flash message at the end of current request (without redirection) |
|
返回顶楼 | |