2013-05-05 38 views
0

我使用引导警惕风格轨闪烁的消息,但我不知道为什么会发生显示提示信息如何防止钢轨两次

def render_flash_msgs 
    unless @_flash_rendered 
     @_flash_rendered = true 
     render 'shared/flash_msgs' 
    end 
end 

    # return html class for flash_key 
    def bootstrap_class_for(flash_key) 
    flash_key == :notice ? 'alert-info' : "alert-#{flash_key}" 
    end 

我不能发布图片,这样我就可以交HTML结果来源

<div id="flash"> 
    <div class="alert" title="Notice"> 
    <button class="close" data-dismiss="alert">×</button> 
    <div>Post was successfully updated.</div> 
    </div> 
    <!-- dont know why it showed again under the alert block --> 
    <p id="notice">Post was successfully updated.</p> 

编辑:--------------------------------- ----------------- 这里是我的表格

= form_for @post do |f| 
    - if @post.errors.any? 
    #error_explanation 
     h2 = "#{pluralize(@post.errors.count, "error")} prohibited this post from being saved:" 
     ul 
     - @post.errors.full_messages.each do |message| 
      li = message 

    .field 
    = f.label :title 
    = f.text_field :title 
    .actions = f.submit 'Save' 

这里是我的闪存页面-----------------------------------

#flash 
    - flash.each do |type, message| 
    .alert class=bootstrap_class_for(type) 
     button.close data-dismiss="alert" 
     | &times; 
     div = message 
+0

你可以发布你的'.html.erb'文件中显示flash消息的部分吗? – Baldrick 2013-05-05 07:50:41

+0

是啊,我已经发布_form和_flash偏分组 – user698855 2013-05-06 00:51:49

回答

0

听起来像你的警报在布局中显示一次,在窗体中显示一次。请向我们展示版面并发帖_form部分。

+0

我刚刚更新了这个问题,但我没有任何在表格页面中的任何重新提交的警报 – user698855 2013-05-05 21:26:57

+0

在哪里调用了render_flash_msgs方法? – 2013-05-06 10:29:02

+0

在application_helper中调用 – user698855 2013-05-07 04:28:39