2016-08-10 78 views
0

我在我的項目上使用Rails 5。html代碼渲染部分後不顯示

我有一個home_controllerindex行動。在索引視圖中,我渲染了部分(_stories.html.erb),但部分之後的代碼不顯示,似乎有時候,如果我從某個頁面返回,它顯示出來。

這裏有什麼問題?

如果我想用index.html.erb(主頁)製作一些佈局部件,那麼正確的方法是什麼?在`index.html.erb'中渲染不同的部分?

index.html.erb

<%= render :partial => 'stories/stories' %> 
<!-- The code below doesn't show up --> 
<button id="myBtn">Open Modal</button> 
<div id="myModal" class="modal"> 
    <div class="modal-content"> 
    <span class="close">×</span> 
    <p>Some text in the Modal..</p> 
    </div> 
</div> 
+0

你的'_stories.html.erb'部分是什麼,如果模態代碼在其他地方工作,那麼它可能是部分錯誤 – lusketeer

+0

@lusketeer謝謝,我重定向到錯誤的URL! –

回答

0

我解決了這個問題,我重定向到錯誤的路徑,這樣的代碼後沒有露面!