Define unbreakable bonds in seed file and guest index

This commit is contained in:
Manuel Bustillo 2024-07-11 23:30:02 +02:00
parent 155278bb7e
commit 16914c874b
3 changed files with 14 additions and 1 deletions

View File

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

View File

@ -10,6 +10,7 @@
<th>Email</th>
<th>Phone</th>
<th>Affinity groups</th>
<th>Unbreakable bonds</th>
<th colspan="2"></th>
</tr>
<% @guests.each_with_index do |guest, i| %>
@ -19,6 +20,7 @@
<td><%= guest.email %></td>
<td><%= guest.phone %></td>
<td><%= guest.affinity_groups.pluck(:name).join(", ") %></td>
<td><%= guest.unbreakable_bonds.pluck(:name).join(", ") %></td>
<td><%= link_to "Show", guest %></td>
<td><%= link_to "Edit", edit_guest_path(guest) %></td>
</tr>

View File

@ -59,3 +59,14 @@ end
guest.affinity_group_list.add(samples.sample)
guest.save!
end
Guest.all.sample(100).each_slice(2) do |a, b|
bond_name = "#{a.full_name} & #{b.full_name}"
a.unbreakable_bond_list.add(bond_name)
b.unbreakable_bond_list.add(bond_name)
a.save!
b.save!
end