2013-10-23 69 views
1

當我通過Hartl Rails教程時,我已經能夠跳過大部分的傷口了,但是我無法弄清楚自己「在10.4左右做錯了。我可以搞定一切正確呈現使用此/static_pages/home.html.erbHartl Rails教程第10章教程:無法回家_feed.html.erb

<% if signed_in? %> 
<div class="row"> 
    <aside class="span4"> 
     <section> 
      <%= render 'shared/user_info' %> 
     </section> 
     <section> 
      <%= render 'shared/micropost_form' %> 
     </section> 
    </aside> 
    </div> 
<% else %> 
<div class="center hero-unit"> 
    <h1>Welcome to The Gentle Introduction Resource</h1> 
    <p> 
     This is the home page for the 
     <a href="http://www.weekendpublisher.com">The Gentle Introduction Resource</a> 
     web app. 
    </p> 

    <%= link_to "Sign up now!", signup_path, class: "btn btn-large btn-primary" %> 
</div> 
<br/> 
<%= link_to image_tag("rails.png", alt: "Rails"), 'http://rubyonrails.org/' %> 

但是當我有這樣的代碼:

<div class="span8"> 
     <h3>Micropost Feed</h3> 
     <%= render 'shared/feed' %> 
    </div> 

它打破。

完全home.html.erb

<% if signed_in? %> 
    <div class="row"> 
     <aside class="span4"> 
      <section> 
       <%= render 'shared/user_info' %> 
      </section> 
      <section> 
       <%= render 'shared/micropost_form' %> 
      </section> 
     </aside> 
     <div class="span8"> 
      <h3>Micropost Feed</h3> 
      <%= render 'shared/feed' %> 
     </div> 
    </div> 
    <% else %> 
    <div class="center hero-unit"> 
     <h1>Welcome to The Gentle Introduction Resource</h1> 
     <p> 
      This is the home page for the 
      <a href="http://www.weekendpublisher.com">The Gentle Introduction Resource</a> 
      web app. 
     </p> 

     <%= link_to "Sign up now!", signup_path, class: "btn btn-large btn-primary" %> 
    </div> 
    <br/> 
    <%= link_to image_tag("rails.png", alt: "Rails"), 'http://rubyonrails.org/' %> 
<% end %> 

Here is my _feed.html.erb: 

    <% If @feed_items.any? %> 
    <ol class="microposts"> 
     <%= render partial: 'shared/feed_item', collection: @feed_items %> 
    </ol> 
    <%= will_paginate @feed_items %> 
    <% end %> 

這裏是我的_feed_item.html.erb

<li id="<%= feed_item.id %>"> 
<%= link_to gravatar_for(feed_item.user), feed_item.user %> 
<span class="user"> 
    <%= link_to feed_item.user.name, feed_item.user %> 
</span> 
<span class="content"><%= feed_item.content %></span> 
<span class="timestamp"> 
    Posted <%= time_ago_in_words(feed_item.created_at) %> ago. 
</span> 
<% if current_user?(feed_item.user) %> 
    <%= link_to "delete", feed_item, method: delete, 
    data: { confirm: "You sure?" }, 
    title: feed_item.content %> 
<% end %> 
</li> 

對不起提前爲我的標記,這是我的第一個堆棧溢出問題。

哦,這裏是當我試圖加載我的本地網站,我發現了錯誤:

的SyntaxError在Static_pages#家

顯示/ rails_projects/sample_appOct20_2013 /應用/視圖/共享/ _feed.html.erb在行#7提出:

/rails_projects/sample_appOct20_2013/app/views/shared/_feed.html.erb:7:語法錯誤,意想不到的keyword_ensure,期待$結束 提取的源(左右線# 7):

4: </ol> 
5: <%= will_paginate @feed_items %> 
6: <% end %> 

跟蹤模板包含的:應用程序/視圖/共享/ _feed.html.erb,應用程序/視圖/ static_pages/home.html.erb

+0

你的routes.rb文件是什麼樣子的? – joncodo

回答

0

我認爲它的資本如果

應:

<% if @feed_items.any? %> 
<ol class="microposts"> 
    <%= render partial: 'shared/feed_item', collection: @feed_items %> 
</ol> 
<%= will_paginate @feed_items %> 
<% end %> 

既然是這樣的話,它認爲不需要<%結束%>標記。它確實是需要的,但是'如果'(大寫)與'if'(小寫)不一樣。

+0

試試魯米姬!它向我展示了在大約2秒內複製並用紅色下劃線粘貼代碼的錯誤。我每天都用它來工作。 – joncodo

+0

喬納森,非常感謝你,這是愚蠢的首都如果我一遍又一遍地失蹤。我會說我的問題得到解答,但看起來我有另一個彈出錯誤。我會搞砸的,並張貼我的發現。再次感謝! – EliCash

+0

好吧,所以我的新錯誤是從添加'<%if current_user?(feed_item.user)%> <%= link_to「delete」,feed_item,method:delete, data:{confirm:「您確定嗎? }, title:feed_item.content%> <% end %>'過早。一旦我隱藏了,一切都很好。只是那個愚蠢的大寫字母,我把我搞亂了! – EliCash

相關問題