Thanks for your reply.
I am going for a display like the following:
Fruit and Meat are category names and apple, orange, peach, etc are type names.
This information is being stored in a join table that look like the following:
post_id keyword_category_id keyword_type_id
1 1 1
1 1 2
1 1 3
The schema look like the following:
I thought I could do the following:
<% @post.keywords.group_by(&:keyword_category).each do |category, type| %>
This code doesn’t work.
I had to use &:keyword_category_id as in the code below. The output look like
I want to display the category names and type names instead of the foreign key ids. I think I am using group_by wrong or even perhaps i need an association in the other direction. I am just baffled at the moment.