Rails Active Record 在未禁止的视图中显示模型行

Rails Active Record Displaying Model Row in View Unbidden

问题: 我对 rails 比较陌生。我想出了如何显示来自关联模型的数据,但是整个 table 行正在呈现在 div 底部的数组中。欢迎大家提出意见。

 [#<ShortTermGoal id: 1, user_id: nil, contact_id: 4, title: "small blah", description: "blah blah blah ", created_at: "2015-05-31 13:58:31", updated_at: "2015-05-31 13:58:31">]

查看代码:

  <div class="group">
    <h3>Personal Goals</h3>
    <div>
      <fieldset>
        <legend>Short Term Goals</legend>
        <div class="row">
          <div class="small-12 columns">
            <ol>
            <%= @contact.short_term_goals.all.each do |short_term_goals| %>
                  <li><strong><%= short_term_goals.title %></strong> <%= simple_format(short_term_goals.description) %> </li>
            <% end %>
            </ol>
          </div>
        </div>
      </fieldset>
      <fieldset>
        <legend>Long Term Goals</legend>
        <div class="row">
          <div class="small-12 columns">
            <%= @contact.long_term_goals.each do |long_term_goals| %>
            <ol>
              <li><strong><%= long_term_goals.title %></strong> <%= simple_format(long_term_goals.description) %></li>
            <% end %>
            </ol>
          </div>
        </div>
      </fieldset>
    </div>
  </div>

您的每个循环都被错误类型的标签包裹。

 V
<% @contact.short_term_goals.all.each do |short_term_goals| %>
   <li><strong><%= short_term_goals.title %></strong> <%= simple_format(short_term_goals.description) %> </li>
<% end %>