Add boosts model
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
class Boost < ApplicationRecord
|
||||
belongs_to :splat
|
||||
belongs_to :creator, class_name: "User", default: -> { Current.user }
|
||||
end
|
||||
@@ -1,4 +1,5 @@
|
||||
class Splat < ApplicationRecord
|
||||
has_many :boosts, dependent: :destroy
|
||||
has_many :categorizations
|
||||
has_many :categories, through: :categorizations, dependent: :destroy
|
||||
has_many :comments, dependent: :destroy
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
class CreateBoosts < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :boosts do |t|
|
||||
t.string :content
|
||||
t.integer :creator_id, null: false
|
||||
t.references :splat, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
Generated
+10
-1
@@ -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_08_14_214252) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2024_08_19_192804) do
|
||||
create_table "accounts", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.datetime "created_at", null: false
|
||||
@@ -18,6 +18,15 @@ ActiveRecord::Schema[8.0].define(version: 2024_08_14_214252) do
|
||||
t.index ["name"], name: "index_accounts_on_name", unique: true
|
||||
end
|
||||
|
||||
create_table "boosts", force: :cascade do |t|
|
||||
t.string "content"
|
||||
t.integer "creator_id", null: false
|
||||
t.integer "splat_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["splat_id"], name: "index_boosts_on_splat_id"
|
||||
end
|
||||
|
||||
create_table "categories", force: :cascade do |t|
|
||||
t.string "title"
|
||||
t.datetime "created_at", null: false
|
||||
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
content: ""
|
||||
creator: :jz
|
||||
splat: one
|
||||
|
||||
two:
|
||||
content: ""
|
||||
creator: :kevin
|
||||
splat: two
|
||||
|
||||
three:
|
||||
content: ""
|
||||
creator: :kevin
|
||||
splat: one
|
||||
|
||||
four:
|
||||
content: ""
|
||||
creator: :jz
|
||||
splat: one
|
||||
@@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class BoostTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user