问题: 我对铁路相对较新。我想出了如何显示来自关联模型的数据,但是整个表行正在渲染为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>
答案 0 :(得分:0)
你的每个循环都被错误的标签包裹着。
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 %>