diff --git a/app/models/splat.rb b/app/models/splat.rb
index 736ec5e5b..3273ca19a 100644
--- a/app/models/splat.rb
+++ b/app/models/splat.rb
@@ -2,6 +2,8 @@ class Splat < ApplicationRecord
has_many :categorizations
has_many :categories, through: :categorizations, dependent: :destroy
+ belongs_to :creator, class_name: "User", default: -> { Current.user }
+
enum :color, %w[
#AF2E1B #CC6324 #3B4B59 #BFA07A #ED8008 #ED3F1C #BF1B1B #736B1E #D07B53
#736356 #AD1D1D #BF7C2A #C09C6F #698F9C #7C956B #5D618F #3B3633 #67695E
diff --git a/app/models/user.rb b/app/models/user.rb
index cac399be3..0cc02e19b 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,6 +1,7 @@
class User < ApplicationRecord
belongs_to :organization
has_many :sessions, dependent: :destroy
+ has_many :splats, dependent: :destroy
has_secure_password validations: false
diff --git a/app/views/splats/show.html.erb b/app/views/splats/show.html.erb
index 73ee70e8c..e50d2efbe 100644
--- a/app/views/splats/show.html.erb
+++ b/app/views/splats/show.html.erb
@@ -41,7 +41,7 @@
diff --git a/db/migrate/20240814210043_add_creator_to_splats.rb b/db/migrate/20240814210043_add_creator_to_splats.rb
new file mode 100644
index 000000000..496d39428
--- /dev/null
+++ b/db/migrate/20240814210043_add_creator_to_splats.rb
@@ -0,0 +1,5 @@
+class AddCreatorToSplats < ActiveRecord::Migration[8.0]
+ def change
+ add_column :splats, :creator_id, :integer, null: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 4ee5fd816..db84ca104 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[8.0].define(version: 2024_07_24_163519) do
+ActiveRecord::Schema[8.0].define(version: 2024_08_14_210043) do
create_table "categories", force: :cascade do |t|
t.string "title"
t.datetime "created_at", null: false
@@ -51,6 +51,7 @@ ActiveRecord::Schema[8.0].define(version: 2024_07_24_163519) do
t.string "color"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.integer "creator_id", null: false
end
create_table "users", force: :cascade do |t|
diff --git a/test/fixtures/splats.yml b/test/fixtures/splats.yml
index b34f9a2fe..7cad9188f 100644
--- a/test/fixtures/splats.yml
+++ b/test/fixtures/splats.yml
@@ -4,13 +4,16 @@ one:
title: The logo isn't big enough
body: Make the logo bigger.
color: '#AF2E1B'
+ creator: :david
two:
title: Layout is broken
body: The page scrolls horizontally on mobile devices.
color: '#CC6324'
+ creator: :jz
three:
title: The text is too small
body: Increase the font size.
color: '#3B4B59'
+ creator: :kevin