Compare commits
5 Commits
fc89c65f20
...
ed7ff876fd
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ed7ff876fd | ||
8732dac0a3 | |||
204771ef2b | |||
16914c874b | |||
155278bb7e |
12
Gemfile.lock
12
Gemfile.lock
@ -91,7 +91,7 @@ GEM
|
|||||||
debug (1.9.2)
|
debug (1.9.2)
|
||||||
irb (~> 1.10)
|
irb (~> 1.10)
|
||||||
reline (>= 0.3.8)
|
reline (>= 0.3.8)
|
||||||
diff-lcs (1.5.0)
|
diff-lcs (1.5.1)
|
||||||
drb (2.2.1)
|
drb (2.2.1)
|
||||||
erubi (1.13.0)
|
erubi (1.13.0)
|
||||||
faker (3.1.1)
|
faker (3.1.1)
|
||||||
@ -204,15 +204,15 @@ GEM
|
|||||||
connection_pool
|
connection_pool
|
||||||
reline (0.5.9)
|
reline (0.5.9)
|
||||||
io-console (~> 0.5)
|
io-console (~> 0.5)
|
||||||
rspec-core (3.12.2)
|
rspec-core (3.12.3)
|
||||||
rspec-support (~> 3.12.0)
|
rspec-support (~> 3.12.0)
|
||||||
rspec-expectations (3.12.3)
|
rspec-expectations (3.12.4)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.12.0)
|
rspec-support (~> 3.12.0)
|
||||||
rspec-mocks (3.12.6)
|
rspec-mocks (3.12.7)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.12.0)
|
rspec-support (~> 3.12.0)
|
||||||
rspec-rails (6.1.0)
|
rspec-rails (6.1.1)
|
||||||
actionpack (>= 6.1)
|
actionpack (>= 6.1)
|
||||||
activesupport (>= 6.1)
|
activesupport (>= 6.1)
|
||||||
railties (>= 6.1)
|
railties (>= 6.1)
|
||||||
@ -220,7 +220,7 @@ GEM
|
|||||||
rspec-expectations (~> 3.12)
|
rspec-expectations (~> 3.12)
|
||||||
rspec-mocks (~> 3.12)
|
rspec-mocks (~> 3.12)
|
||||||
rspec-support (~> 3.12)
|
rspec-support (~> 3.12)
|
||||||
rspec-support (3.12.1)
|
rspec-support (3.12.2)
|
||||||
sprockets (4.2.1)
|
sprockets (4.2.1)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
rack (>= 2.2.4, < 4)
|
rack (>= 2.2.4, < 4)
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
class GuestsController < ApplicationController
|
class GuestsController < ApplicationController
|
||||||
before_action :set_guest, only: %i[ show edit update destroy ]
|
before_action :set_guest, only: %i[show edit update destroy]
|
||||||
|
|
||||||
# GET /guests or /guests.json
|
# GET /guests or /guests.json
|
||||||
def index
|
def index
|
||||||
@guests = Guest.all.includes(:affinity_groups)
|
@guests = Guest.all
|
||||||
|
.left_outer_joins(:affinity_groups)
|
||||||
|
.order('tags.name' => :asc)
|
||||||
|
.includes(:affinity_groups, :unbreakable_bonds)
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /guests/1 or /guests/1.json
|
# GET /guests/1 or /guests/1.json
|
||||||
def show
|
def show; end
|
||||||
end
|
|
||||||
|
|
||||||
# GET /guests/new
|
# GET /guests/new
|
||||||
def new
|
def new
|
||||||
@ -16,8 +18,7 @@ class GuestsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
# GET /guests/1/edit
|
# GET /guests/1/edit
|
||||||
def edit
|
def edit; end
|
||||||
end
|
|
||||||
|
|
||||||
# POST /guests or /guests.json
|
# POST /guests or /guests.json
|
||||||
def create
|
def create
|
||||||
@ -25,7 +26,7 @@ class GuestsController < ApplicationController
|
|||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @guest.save
|
if @guest.save
|
||||||
format.html { redirect_to guest_url(@guest), notice: "Guest was successfully created." }
|
format.html { redirect_to guest_url(@guest), notice: 'Guest was successfully created.' }
|
||||||
format.json { render :show, status: :created, location: @guest }
|
format.json { render :show, status: :created, location: @guest }
|
||||||
else
|
else
|
||||||
format.html { render :new, status: :unprocessable_entity }
|
format.html { render :new, status: :unprocessable_entity }
|
||||||
@ -38,7 +39,7 @@ class GuestsController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @guest.update(guest_params)
|
if @guest.update(guest_params)
|
||||||
format.html { redirect_to guest_url(@guest), notice: "Guest was successfully updated." }
|
format.html { redirect_to guest_url(@guest), notice: 'Guest was successfully updated.' }
|
||||||
format.json { render :show, status: :ok, location: @guest }
|
format.json { render :show, status: :ok, location: @guest }
|
||||||
else
|
else
|
||||||
format.html { render :edit, status: :unprocessable_entity }
|
format.html { render :edit, status: :unprocessable_entity }
|
||||||
@ -52,12 +53,13 @@ class GuestsController < ApplicationController
|
|||||||
@guest.destroy!
|
@guest.destroy!
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to guests_url, notice: "Guest was successfully destroyed." }
|
format.html { redirect_to guests_url, notice: 'Guest was successfully destroyed.' }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_guest
|
def set_guest
|
||||||
@guest = Guest.find(params[:id])
|
@guest = Guest.find(params[:id])
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
<th>Email</th>
|
<th>Email</th>
|
||||||
<th>Phone</th>
|
<th>Phone</th>
|
||||||
<th>Affinity groups</th>
|
<th>Affinity groups</th>
|
||||||
|
<th>Unbreakable bonds</th>
|
||||||
<th colspan="2"></th>
|
<th colspan="2"></th>
|
||||||
</tr>
|
</tr>
|
||||||
<% @guests.each_with_index do |guest, i| %>
|
<% @guests.each_with_index do |guest, i| %>
|
||||||
@ -19,6 +20,7 @@
|
|||||||
<td><%= guest.email %></td>
|
<td><%= guest.email %></td>
|
||||||
<td><%= guest.phone %></td>
|
<td><%= guest.phone %></td>
|
||||||
<td><%= guest.affinity_groups.pluck(:name).join(", ") %></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 "Show", guest %></td>
|
||||||
<td><%= link_to "Edit", edit_guest_path(guest) %></td>
|
<td><%= link_to "Edit", edit_guest_path(guest) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
18
db/seeds.rb
18
db/seeds.rb
@ -28,7 +28,10 @@ Expense.create!(name: 'Transportation', amount: 3000, pricing_type: 'fixed')
|
|||||||
Expense.create!(name: 'Invitations', amount: 200, pricing_type: 'fixed')
|
Expense.create!(name: 'Invitations', amount: 200, pricing_type: 'fixed')
|
||||||
Expense.create!(name: 'Cake', amount: 500, pricing_type: 'fixed')
|
Expense.create!(name: 'Cake', amount: 500, pricing_type: 'fixed')
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
|
=======
|
||||||
|
>>>>>>> 8fd0b7c (Modify seeds file to make sure every guest is part of a group)
|
||||||
samples = {
|
samples = {
|
||||||
close_family: 10,
|
close_family: 10,
|
||||||
family_1_group_a: 5,
|
family_1_group_a: 5,
|
||||||
@ -56,3 +59,18 @@ end
|
|||||||
guest.affinity_group_list.add(samples.sample)
|
guest.affinity_group_list.add(samples.sample)
|
||||||
guest.save!
|
guest.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Guest.affinity_group_counts.each do |group|
|
||||||
|
couples = (group.taggings_count / 4).floor
|
||||||
|
|
||||||
|
guests_involved = Guest.tagged_with(group.name).limit(couples * 2)
|
||||||
|
guests_involved.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
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user