diff --git a/Gemfile b/Gemfile
index 7b27dc7..a3cbafd 100644
--- a/Gemfile
+++ b/Gemfile
@@ -49,6 +49,7 @@ group :development, :test do
gem "debug", platforms: %i[ mri windows ]
gem 'rspec-rails', '~> 6.1.0'
gem 'faker'
+ gem 'pry'
end
group :development do
diff --git a/Gemfile.lock b/Gemfile.lock
index c1556c5..6f951a1 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -83,6 +83,7 @@ GEM
bootsnap (1.18.3)
msgpack (~> 1.2)
builder (3.3.0)
+ coderay (1.1.3)
concurrent-ruby (1.3.3)
connection_pool (2.4.1)
crass (1.0.6)
@@ -119,6 +120,7 @@ GEM
net-pop
net-smtp
marcel (1.0.4)
+ method_source (1.0.0)
mini_mime (1.1.5)
minitest (5.24.1)
money (6.16.0)
@@ -148,6 +150,9 @@ GEM
nokogiri (1.16.6-x86_64-linux)
racc (~> 1.4)
pg (1.5.6)
+ pry (0.14.2)
+ coderay (~> 1.1)
+ method_source (~> 1.0)
psych (5.1.2)
stringio
puma (6.4.2)
@@ -262,6 +267,7 @@ DEPENDENCIES
jbuilder
money
pg (~> 1.1)
+ pry
puma (>= 5.0)
rails (~> 7.1.3, >= 7.1.3.2)
redis (>= 4.0.1)
diff --git a/app/models/guest.rb b/app/models/guest.rb
index 109a01b..60e3bc2 100644
--- a/app/models/guest.rb
+++ b/app/models/guest.rb
@@ -1,4 +1,6 @@
class Guest < ApplicationRecord
+ acts_as_taggable_on :affinity_groups, :unbreakable_bonds
+
def full_name
"#{first_name} #{last_name}"
end
diff --git a/app/views/guests/index.html.erb b/app/views/guests/index.html.erb
index a498755..690588c 100644
--- a/app/views/guests/index.html.erb
+++ b/app/views/guests/index.html.erb
@@ -9,6 +9,7 @@
Name |
Email |
Phone |
+ Affinity groups |
|
<% @guests.each_with_index do |guest, i| %>
@@ -17,6 +18,7 @@
<%= guest.full_name %> |
<%= guest.email %> |
<%= guest.phone %> |
+ <%= guest.affinity_group_list %> |
<%= link_to "Show", guest %> |
<%= link_to "Edit", edit_guest_path(guest) %> |
diff --git a/db/migrate/20240711181626_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb b/db/migrate/20240711181626_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb
index 4690763..8b97ba6 100644
--- a/db/migrate/20240711181626_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb
+++ b/db/migrate/20240711181626_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb
@@ -13,7 +13,7 @@ class ActsAsTaggableOnMigration < ActiveRecord::Migration[6.0]
# You should make sure that the column created is
# long enough to store the required class names.
- t.references :taggable, polymorphic: true
+ t.references :taggable, polymorphic: true, type: :uuid
t.references :tagger, polymorphic: true
# Limit is created to prevent MySQL error on index
diff --git a/db/schema.rb b/db/schema.rb
index 0ec1413..7410759 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -38,7 +38,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_07_11_181632) do
create_table "taggings", force: :cascade do |t|
t.bigint "tag_id"
t.string "taggable_type"
- t.bigint "taggable_id"
+ t.uuid "taggable_id"
t.string "tagger_type"
t.bigint "tagger_id"
t.string "context", limit: 128
diff --git a/db/seeds.rb b/db/seeds.rb
index b21fb7b..7a9fa04 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -10,6 +10,8 @@
Expense.delete_all
Guest.delete_all
+ActsAsTaggableOn::Tagging.delete_all
+ActsAsTaggableOn::Tag.delete_all
Expense.create!(name: 'Photographer', amount: 3000, pricing_type: 'fixed')
Expense.create!(name: 'Country house', amount: 6000, pricing_type: 'fixed')
@@ -32,3 +34,26 @@ Expense.create!(name: 'Cake', amount: 500, pricing_type: 'fixed')
email: Faker::Internet.email,
phone: Faker::PhoneNumber.cell_phone)
end
+
+{
+ close_family: 10,
+ family_1_group_a: 5,
+ family_1_group_b: 5,
+ family_2_group_a: 7,
+ family_2_group_b: 15,
+ previous_company: 5,
+ new_company: 15,
+ college: 10,
+ high_school: 5,
+ childhood: 5,
+ basket_team: 20,
+ soccer_team: 15,
+ dance_club: 10
+}.each do |affinity_group, count|
+ Guest.all.sample(count).each do |guest|
+ guest.affinity_group_list.add(affinity_group)
+ guest.save!
+ rescue => e
+ binding.pry
+ end
+end