2012-08-01 97 views
1

在我的Rails應用程序中,我使用Twitter引導程序。Bootstrap模式顯示兩次

之前,一切正常,但突然模式開始顯示兩次。 我不知道發生了什麼事。我的代碼如下所示。

色器件/註冊/ new.html.erb

<%= link_to "Terms of Service", terms_in_modal_path, {:class => "show-terms", :remote => true} 

pages_controller
def terms_in_modal 
    respond_to do |format| 
    format.js 
    end 
end 

terms_in_modal.js.erb
$("#signup-modal").html('<%= escape_javascript render(:partial => "terms_in_modal") %>'); 
$('#show-terms').modal('show'); 

_terms_in_modal.html.erb
<div id="show-terms" class="modal hide fade in"> 
... 
</div> 

點擊鏈接後,出現兩個模塊,輸出html如下所示。

<div id="signup-modal"> 
    <div id="show-terms" class="modal hide fade in" style="display: block; "> 
    <div class="modal-header"> 
    ... 
    </div> 
</div> 

<div class="modal-backdrop fade in"></div> 
<div class="modal-backdrop fade in"></div> 

<div id="show-terms" class="modal hide fade in" style="display: block; "> 
    <div class="modal-header"> 
    ... 
</div> 

EDIT1

在在Heroku上,模態做工精細我升級的應用程序。 奇怪的是,我上次推Herku後沒有編輯與模式和註冊頁面相關的任何內容。 我最近將操作系統更改爲Mountain Lion,因此它可能與操作系統有關。

EDIT2

我做「混帳推分期主」和嘗試,如果模式將正常工作,並且工作正常。 非常奇怪..

回答

2

它在您的本地環境中這樣做很可能是因爲您需要用於Heroku的編譯資產與資產相沖突當您在開發環境中時,Rails包括在運行中。爲了防止這種情況發生,您最有可能只需要rm -rf public/assets即可刪除預編譯的資產。在每次推送到Heroku之前,您都應該確保重新編譯它們。

+0

我試過你的解決方案,現在模態在我的本地服務器上正常工作,謝謝。我認爲我的載波和環境設置有問題。導致我在嘗試資源時不斷收到錯誤:預編譯。不管怎樣,謝謝! – 2012-08-02 02:48:01

+0

如果我的答案是解決您的問題,請隨時查看綠色箭頭。 :d – John 2012-08-02 03:01:20