Reputation: 18781
I have a two way many-to-many assoication between 3 models: work.rb, category.rb, categorywork.rb
Within the work#index
using <%= work.categories %>
renders some wonky looking html markup
<% @works.each do |work| %>
<tr>
<td><%= work.name %></td>
<td><%= work.subtitle %></td>
<td><%= work.categories %></td>
<td><%= link_to 'Show', work %></td>
<td><%= link_to 'Edit', edit_work_path(work) %></td>
<td><%= link_to 'Destroy', work, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
I'm trying to target speific attributes of the association like "name".
Unfortunately when using <%= work.categories.name %>
it gets weirder with:
How do i target just the name or just the description?
Upvotes: 0
Views: 20