2013-05-05 35 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