ruby-on-rails - Rails 语法错误 : unexpected keyword_ensure, 期望输入结束

标签 ruby-on-rails ruby ruby-on-rails-3

我是 Rails 的新手,我尝试根据教程创建一个论坛应用程序。这是我的论坛页面,但我一直收到错误消息:

syntax error, unexpected keyword_ensure, expecting end-of-input

Extracted source (around line #33):
30 
31    <p><% if admin? %><%= link_to "New Forum", new_forum_path %><% end %></p>  

这是抛出错误的论坛索引页面:

<% title "Forums" %>  

<table>  
  <tr>  
    <th width="70%">Forum</th>  
    <th width="30%">Last Post</th>  
  </tr>  
  <% for forum in @forums %>  
    <tr>  
      <td><h4><%= link_to h(forum.name), forum_path(forum.id) %></h4>  
        <small><%= forum.topics.count %> topics</small><br />  
        <%=h forum.description %></td>  
      <td class="right">
      <% if forum.most_recent_post %>
      <%= distance_of_time_in_words_to_now forum.most_recent_post.last_post_at %>
       ago by 
       <%= link_to forum.most_recent_post.user.username, "/users/#{forum.most_recent_post.last_poster_id}" %>
       <% else %>no posts<% end %>
       </td>  
      <% if admin? %>
      <td><%= link_to "Edit", edit_forum_path(forum) %>
  <% end %></td>
  <!-- <% end %> -->  
  <% if admin? %>
  <td><%= link_to "Destroy", forum, :confirm => 'Are you sure?', :method => :delete %></td>
  <% end %>  
</tr>  
  <% end %>  

<p><% if admin? %><%= link_to "New Forum", new_forum_path %><% end %></p>  

最佳答案

<!-- <% end %> -->这是在做什么?一个 html 注释的 ERB 标签仍然会评估。去掉它。如果您想评论 ruby​​ 代码,请使用 #相反,像 <% #end %>

关于ruby-on-rails - Rails 语法错误 : unexpected keyword_ensure, 期望输入结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19463053/

相关文章:

html - 使用 nokogiri 和 ruby​​ on rails 更改 href 属性

ruby-on-rails - 自定义404无法从 Controller 触发

ruby-on-rails - 开源 ruby​​ 和 rails 项目

ruby-on-rails-3 - rails rspec http 基本认证测试

ruby-on-rails - 如何让 url_helper 在 Rails 中传递永久链接而不是 id?

ruby-on-rails - Rails 中的 REST API 参数验证

javascript - 如何通过论证 Rails

javascript - 远程刷新页面=>真正的模式表单提交

ruby - 我怎样才能完全重置我的 Ruby 安装?

ruby-on-rails - 为什么 SimpleForm 不适用于日期字段?