Define unbreakable bonds in seed file and guest index
This commit is contained in:
parent
155278bb7e
commit
16914c874b
@ -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
|
||||
|
@ -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>
|
||||
|
11
db/seeds.rb
11
db/seeds.rb
@ -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
|
Loading…
x
Reference in New Issue
Block a user