Rails Active Record с отображением строки модели в виде Unbidden
Вопрос: я относительно новичок в рельсах. Я выяснил, как отображать данные из связанных моделей, однако вся строка таблицы отображается в виде массива в нижней части элемента 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>
1 ответ
Решение
Каждый ваш цикл заключен в неправильный тип тега.
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 %>