Compare commits
7 Commits
b36636345a
...
b09ee895a6
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b09ee895a6 | ||
0b7b7fdbe8 | |||
![]() |
17ffd2fea7 | ||
d9b63e4588 | |||
beeda19186 | |||
d912bc0ed0 | |||
![]() |
a2db2a2af7 |
14
Gemfile.lock
14
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.4.2)
|
faker (3.4.2)
|
||||||
@ -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)
|
||||||
@ -233,7 +233,7 @@ GEM
|
|||||||
stringio (3.1.1)
|
stringio (3.1.1)
|
||||||
thor (1.3.1)
|
thor (1.3.1)
|
||||||
timeout (0.4.1)
|
timeout (0.4.1)
|
||||||
turbo-rails (2.0.5)
|
turbo-rails (2.0.6)
|
||||||
actionpack (>= 6.0.0)
|
actionpack (>= 6.0.0)
|
||||||
activejob (>= 6.0.0)
|
activejob (>= 6.0.0)
|
||||||
railties (>= 6.0.0)
|
railties (>= 6.0.0)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
require 'csv'
|
||||||
|
|
||||||
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]
|
||||||
|
|
||||||
@ -58,6 +60,20 @@ class GuestsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def import
|
||||||
|
csv = CSV.parse(params[:file].read, headers: true)
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
|
csv.each do |row|
|
||||||
|
guest = Guest.create!(first_name: row['name'])
|
||||||
|
|
||||||
|
guest.affinity_group_list.add(row['affinity_group'])
|
||||||
|
guest.save!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to guests_url
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
|
@ -29,3 +29,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= link_to "New guest", new_guest_path %>
|
<%= link_to "New guest", new_guest_path %>
|
||||||
|
|
||||||
|
<%= form_with url: import_guests_path, method: :post do |form| %>
|
||||||
|
<%= form.label :file %>
|
||||||
|
<%= form.file_field :file %>
|
||||||
|
<%= form.submit "Import" %>
|
||||||
|
<% end %>
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
resources :guests
|
resources :guests do
|
||||||
|
post :import, on: :collection
|
||||||
|
end
|
||||||
resources :expenses
|
resources :expenses
|
||||||
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
||||||
|
|
||||||
|
@ -28,10 +28,6 @@ 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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user