`
peryt
  • 浏览: 52365 次
  • 来自: ...
最近访客 更多访客>>
社区版块
存档分类
最新评论
  • waiting: 既然都指定了dataType为'script'那就不必特别在b ...
    jQuery

9.1 about flash.now[:error] vs flash[:error]

 
阅读更多

There’s a subtle difference between flash and flash.now. The flash variable is designed to be used before a redirect, and it persists on the resulting page for one request—that is, it appears once, and disappears when you click on another link. Unfortunately, this means that if we don’t redirect, and instead simply render a page (as in Listing 9.8), the flash message persists for two requests: it appears on the rendered page but is still waiting for a “redirect” (i.e., a second request), and thus appears again if you click a link.

To avoid this weird behavior, when rendering rather than redirecting we use flash.nowinstead of flash. The flash.now object is specifically designed for displaying flash messages on rendered pages. If you ever find yourself wondering why a flash message is showing up where you don’t expect it, chances are good that you need to replace flash withflash.now.

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics