Avoid N+1 queries with acts_as_taggable

This commit is contained in:
Manuel Bustillo 2024-07-11 23:20:32 +02:00
parent 3660d14d44
commit 0814c7cab5
2 changed files with 2 additions and 2 deletions

View File

@ -3,7 +3,7 @@ class GuestsController < ApplicationController
# GET /guests or /guests.json # GET /guests or /guests.json
def index def index
@guests = Guest.all @guests = Guest.all.includes(:affinity_groups)
end end
# GET /guests/1 or /guests/1.json # GET /guests/1 or /guests/1.json

View File

@ -18,7 +18,7 @@
<td><%= guest.full_name %></td> <td><%= guest.full_name %></td>
<td><%= guest.email %></td> <td><%= guest.email %></td>
<td><%= guest.phone %></td> <td><%= guest.phone %></td>
<td><%= guest.affinity_group_list %></td> <td><%= guest.affinity_groups.pluck(:name).join(", ") %></td>
<td><%= link_to "Show", guest %></td> <td><%= link_to "Show", guest %></td>
<td><%= link_to "Edit", edit_guest_path(guest) %></td> <td><%= link_to "Edit", edit_guest_path(guest) %></td>
</tr> </tr>