Creating a simple todolist. Trying to show the description for a task that belongs to a list in the list index view. With the current code all data fields shows up from all tasks that belongs to the list when i use list.tasks, but i only want the task.desc. How do i specifically tell rails that i only want the task.desc to show up?
lists/index.html.erb
<h1>My Lists</h1>
<%= link_to 'New List', new_list_path, class: "btn btn-primary" %>
<h3>Name | Time Ago</h3>
<% @lists.each do |list| %>
<h4><%= link_to list.name, list %></td></h4>
<% if list.created_at > Time.now.beginning_of_day %>
<%="#{time_ago_in_words(list.created_at)} ago"%>
<% else %>
<h6><%= list.created_at.strftime("%b %d, %Y") %></h6>
<%= list.tasks %><br />
<% end %>
<%= link_to 'Edit', edit_list_path(list) %> |
<%= link_to 'Destroy', list, method: :delete, data: { confirm: 'Are you sure?' } %>
<br />
<% end %>
<br />
If i understand correctly your problem, you can use .each, which you have used for list iteration: