2013-10-23 68 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

相关问题